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!