Surf plot for three independent matrices of 1x360

조회 수: 3 (최근 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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by