How can I plot a mesh?
13 views (last 30 days)
Show older comments
I have three variables X,Y and Z, Z is calculated from row vectors of X and Y and then I want to plot a mesh of Z using X and Y as grid... I know how to meshgrid but I dont know how to extend Z vector corresponding to X and Y grid?
0 Comments
Accepted Answer
Star Strider
on 9 Jul 2015
Use meshgrid to create the ‘X’ and ‘Y’ meshes, then calculate ‘Z’ from them:
x = linspace(-3, 3, 50);
y = linspace(-1.5, 1.5, 30);
[X,Y] = meshgrid(x, y);
Z = sin(X) .* exp(Y);
figure(1)
mesh(X, Y, Z)
grid on
Note the use of element-wise multiplication (.*) in ‘Z’.
0 Comments
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!