Why can't I generate a 3-d surface when using surf? (file)
1 回表示 (過去 30 日間)
古いコメントを表示
My version is 2015b. I use Mac.
x=linspace(-2,2,20);
y=x';
z=y*x;
surf(x,y,z)
And the output has nothing, shownd in picture.
0 件のコメント
回答 (1 件)
Cris LaPierre
2022 年 1 月 22 日
Z must be a matrix. In your code, it is only a vector. Follow the eamples on the surf documentation page. You will find meshgrid helpful for this purpose.
x=linspace(-2,2,20);
y=x';
[X,Y] = meshgrid(x,y);
Z = X.*Y;
surf(x,y,Z)
3 件のコメント
参考
カテゴリ
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!