Surf plot for three independent matrices of 1x360
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
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 Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!