Does the surf command have plotting errors?
1 view (last 30 days)
Show older comments
The following code does not produce the correct plot:
Trial>> [X,Y]=meshgrid(-2.5:0.2:2.5)
Trial>> Z=(X.^2+3*Y.^2)*exp(1-X.^2-Y.^2);
Trial>> surf(X,Y,Z)
0 Comments
Accepted Answer
Star Strider
on 9 Jan 2016
You have to do element-wise multiplication in your ‘Z’ assignment:
Z=(X.^2+3*Y.^2).*exp(1-X.^2-Y.^2);
^ <— ADD DOT OPERATOR HERE
[X,Y]=meshgrid(-2.5:0.2:2.5);
Z=(X.^2+3*Y.^2).*exp(1-X.^2-Y.^2);
figure(1)
surf(X,Y,Z)
grid on
0 Comments
More Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading 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!