Using the surf and meshgrid command
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
lateef
am 25 Mär. 2023
Kommentiert: Star Strider
am 26 Mär. 2023
i am trying to plot a function using the surf and meshgrid commands
use the meshgrid and surf commands to plot y = sin(x cos(z)))
this is the code i have so far im not sure how to continue using the surf command and what is wrong with my current code
x = linspace(-1,1);
y = linspace(-1,1);
[x,y] = meshgrid(x,y);
y = sin*(x cos(z))
0 Kommentare
Akzeptierte Antwort
Star Strider
am 25 Mär. 2023
I am not certain what function you want to plot, since you did not create ‘z’ as a separate matrix. (I am creating it here in place of matrix ‘y’.
Since this is a bit ambiguous, two options —
x = linspace(-1,1, 50);
z = linspace(-1,1, 50);
[x,z] = meshgrid(x,z);
y = sin(x.*cos(z));
figure
surf(x, y, z)
colormap(turbo)
figure
surf(x, z, y)
colormap(turbo)
.
3 Kommentare
Star Strider
am 26 Mär. 2023
@lateef — This should work, then.
I am just not certain what is to be plotted, or how it is to be plotted, since ‘z’ is not specifically defined anywhere.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!