How to mesh plot sum of sine waves

2 visualizzazioni (ultimi 30 giorni)
서영 이
서영 이 il 28 Mag 2022
Commentato: Star Strider il 28 Mag 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)

Risposta accettata

Star Strider
Star Strider il 28 Mag 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 Commenti
서영 이
서영 이 il 28 Mag 2022
Thank you so much for helping me.
I was working with it for a long time..
You are awesome!
Star Strider
Star Strider il 28 Mag 2022
As always, my pleasure!
Thank you!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by