Help with 3D plot and meshgrid
이전 댓글 표시
I have a meshgrid of variables X and Y defined as
x=[-25:0.5:24.5];
y=[-25:0.5:24.5];
[X,Y]=meshgrid(x,y);
and have a vector of 10,000 data points, called W.
I would like to make a 3D plot of the data points along x and y. The data points need to be plotted at x and y locations as illustrated below:
Data point 1: x = -25 y = -25
Data point 2: x = -25 y = -24.5
Data point 3: x = -25 y = -24
...
Data point 100: x = -25 y = 24.5
Data point 101: x = -24.5 y = -25
Data point 102: x = -24.5 y = -24.5
...
Data point 200: x = -24.5 y = 24.5
...
Data point 10000: x = 24.5 y = 24.5
Thanks for your help.
I am using MATLAB R2012a.
답변 (1개)
Evan
2013년 7월 15일
You could use the reshape command to turn your matrix v into one with the same size as your mesh, then plot using a command like surface, plot3, or scatter3
x = [-25:0.5:24.5];
y = [-25:0.5:24.5];
[X,Y] = meshgrid(x,y);
v = 1:10000;
v = reshape(v,size(X,1),size(X,2));
surface(X,Y,v)
카테고리
도움말 센터 및 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!