How to mesh plot sum of sine waves
2 views (last 30 days)
Show older comments
Hello.
I am working on a project for school.
When I run the code, it tells me that 'Z' needs to be a matrix.
I would appreciate any help.
x=-1:0.01:1;
y=-1:0.01:1;
[X,Y]=meshgrid(x,y);
Z=80.*sin(150*x)+90.*sin(200*x);
mesh(X,Y,Z)
0 Comments
Accepted Answer
Star Strider
on 28 May 2022
Give it the ‘X’ and ‘Y’ matrix arguments rather than the vector arguments —
x=-1:0.01:1;
y=-1:0.01:1;
[X,Y]=meshgrid(x,y);
Z=80.*sin(150*X)+90.*sin(200*Y);
figure
mesh(X,Y,Z)
With that change, it works.
.
2 Comments
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D 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!