Surf plot for three independent matrices of 1x360

1 回表示 (過去 30 日間)
Anisha Varughese
Anisha Varughese 2019 年 8 月 8 日
コメント済み: Star Strider 2019 年 8 月 9 日
Hey , I have three matrices of equal dimensions and i want to make a surf plot for it. Can someone help me with it. Basically X,Y are coordinates of the position and Z is the value at that Point. Thanks in advance for everyone who tries to help.

採用された回答

Star Strider
Star Strider 2019 年 8 月 8 日
You have one matrix of three (1x360) row vectors. If your data are gridded, simply use the reshape function on each row vector to create appropriate matrices from them.
If your data are not gridded (random), use the griddata function (or similar functions) to create appropriate matrices for the surf plot.
One easy way to see if your data are gridded is to plkot them using the stem3 function. If they are gridded, that will be obvious.
  10 件のコメント
Anisha Varughese
Anisha Varughese 2019 年 8 月 9 日
X and Y are coordinates and Z is velocity at that position. The files are too big to attach. sorry.
Star Strider
Star Strider 2019 年 8 月 9 日
X and Y are coordinates and Z is velocity at that position.
That means that your two independent variable vectors are ‘X’ and ‘Y’, and your dependent variable vector is ‘Z’. My original Answer using griddata should work with your vectors.
A (3x360) matrix should not be too large to attach here.
Try this with your data:
X = rand(1, 360); % Create Vector
Y = rand(1, 360); % Create Vector
Z = rand(1, 360); % Create Vector
N = 50; % Grid Matrix Size
xv = linspace(min(X), max(X), N); % ‘X’ Vector To Define Interpolation Matrix
yv = linspace(min(Y), max(Y), N); % ‘Y’ Vector To Define Interpolation Matrix
[Xm,Ym] = meshgrid(xv, yv); % Create Interpolation Matrices
Zm = griddata(X, Y, Z, Xm, Ym); % Interpolate Vectors To Grids
figure
surfc(Xm, Ym, Zm)
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
That should work with your vectors without further modification. Much depends on the vectors themselves, of course, and I do not have them to work with.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by