How to mesh plot sum of sine waves

1 view (last 30 days)
서영 이
서영 이 on 28 May 2022
Commented: Star Strider on 28 May 2022
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)

Accepted Answer

Star Strider
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
Star Strider
Star Strider on 28 May 2022
As always, my pleasure!
Thank you!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!