Which function do I need to use to plot 3D

조회 수: 2 (최근 30일)
Alex Rzhishev
Alex Rzhishev 2020년 3월 12일
댓글: Steven Lord 2020년 3월 12일
I am trying to plot this 3D, and I cant come up with the necessary function.

답변 (2개)

Alex Mcaulley
Alex Mcaulley 2020년 3월 12일
Try surf
  댓글 수: 1
Alex Rzhishev
Alex Rzhishev 2020년 3월 12일
Thanks for the response, This is the code I have now, my only problem is the Z definition
xx = linspace(-10,10,20);
yy = linspace(10,-10,20);
[X,Y] = meshgrid(xx,yy);
Z = -X.^2 -Y.^2 + 200;
figure
surf(X,Y,Z)
xlabel('x'), ylabel('y'), zlabel('z')
view([-21 48])
What should I insert to the Z to have exact 3D like the image above?

댓글을 달려면 로그인하십시오.


Sriram Tadavarty
Sriram Tadavarty 2020년 3월 12일
Hi Alex,
Based on the image, the surf function can provide the desired output. The usage details of surf command can be found here https://www.mathworks.com/help/matlab/ref/surf.html
There are other 3d plot functions in MATLAB which can be used. The documentation links of those are
Hope this helps.
Regards,
Sriram
  댓글 수: 1
Steven Lord
Steven Lord 2020년 3월 12일
As a bit of a generalization of what Sriram said, if you know what you want the plot to look like but aren't sure if there's a function in MATLAB to create it, open the Plots tab on the Toolstrip. Expand the Plots section by pressing the downward facing triangle and look for a thumbnail that looks close to what you want. Underneath each thumbnail will be the name of the related function.
If you have the variable(s) you want to plot selected in the Workspace window, you can limit what gets shown to what is applicable to those variables or even just click on the thumbnail and have MATLAB plot the selected data using that function.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by