xyzφデータ入力のgradient演算

2 vues (au cours des 30 derniers jours)
繁
le 19 Fév 2023
Commenté : le 17 Mar 2023
x,y,z座標とその場所のスカラ値φで構成される4列複数行のテーブルデータがあります。このデータのgradient(勾配)を求める方法を教えてもらえますか?
gradient関数のドキュメントを確認すると、xyzの行列にしてあげれば演算可能なようですが、本データのxyzは等間隔でない位置関係にあります。
よろしくお願いします。

Réponse acceptée

COVAO
COVAO le 13 Mar 2023
Déplacé(e) : Atsushi Ueno le 15 Mar 2023
等間隔でないx,y,zデータは、scatteredInterpolant関数を用いて等間隔の点に補間し、gradient関数で勾配を算出することができます。
一様に分布していないデータの表面をプロットする例が、以下のドキュメントにあります。
x = rand(100,1)*16 - 8;
y = rand(100,1)*16 - 8;
r = sqrt(x.^2 + y.^2) + eps;
z = sin(r)./r;
xlin = linspace(min(x),max(x),33);
ylin = linspace(min(y),max(y),33);
[X,Y] = meshgrid(xlin,ylin);
f = scatteredInterpolant(x,y,z);
Z = f(X,Y);
z = sin(r)./r;
figure
mesh(X,Y,Z) %interpolated
axis tight; hold on
plot3(x,y,z,'.','MarkerSize',15) %nonuniform
figure
contour(X,Y,Z)
hold on
[fx,fy] = gradient(Z,0.1);
quiver(X,Y,fx,fy)
hold off
  1 commentaire
繁
le 17 Mar 2023
ありがとうございます。こちらで問題解決できました。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 内挿 dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!