Help with 3D plot and meshgrid
Afficher commentaires plus anciens
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.
Réponses (1)
Evan
le 15 Juil 2013
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)
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!