Z must be a matrix, not a scalar or vector.
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Voss
2022 年 12 月 3 日
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)
回答 (2 件)
Eric Delgado
2022 年 12 月 3 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!