Z must be a matrix, not a scalar or vector.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
t=0:30
x=(1+0.25.*cos(45.*t)).*cos(t)
y=(1+0.25.*cos(45.*t)).*sin(t)
[X,Y] = meshgrid(x,y)
Z=t+2.*sin(45.*t)
surf(X,Y,Z)
not sure why it keep told me the "Z must be a matrix, not a scalar or vector."
Thanks for the help!!
1 commentaire
Voss
le 3 Déc 2022
Maybe you intend to make a line in 3D rather than a surface?
t = 0:30;
x = (1+0.25.*cos(45.*t)).*cos(t);
y = (1+0.25.*cos(45.*t)).*sin(t);
z = t+2.*sin(45.*t);
plot3(x,y,z)
Réponses (2)
Eric Delgado
le 3 Déc 2022
You have have a grid created by meshgrid, so you need a matrix to fill this grid. Not a vector...
It is what it is! :)
t=0:30;
x=(1+0.25.*cos(45.*t)).*cos(t);
y=(1+0.25.*cos(45.*t)).*sin(t);
[X,Y] = meshgrid(x,y);
Z = randn(size(X));
surf(X,Y,Z)
0 commentaires
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!