Need to plot x^2+y^2=z^2; plot in 3D ; also obtain 2D cut in xy plane. How od I do this. Thanks

조회 수: 11 (최근 30일)
Need to plot x^2+y^2=z^2; plot in 3D ; also obtain 2D cut in xy plane. How od I do this. Thanks

채택된 답변

Björn
Björn 2012년 10월 15일
There are several ways to do this. First you need to create the x- and y- arrays. This can be done using:
x=x_min:dx:x_max
y=(y_min:dy:y_max)'
x_min, y_min are the minimum values you want for x and y respectively. x_max, y_max are the maximum values. And dx, dy are the step-size between the different points. I take the transpose of y to be able to use BSXFUN so you don't have to create a loop to create the z-matrix.
The z-matrix can then be created by:
z=bsxfun(@plus,x.^2,y.^2)
note that the z-value is in fact z^2.
Next you can plot the 3D-surface using:
surf(x,y,z,'linestyle','none')
The part: 'linestyle','none' suppresses the gridlines, which in the case of a big matrix, you don't want to be shown.
Now if you want to have a 2D cut (or intensity-graph) in the xy plane, you add the command:
view(0,90) % Shows graph from top-view
camva(7) % Camera viewing angle. Alter to increase or decrease size of plot
Hope this is what you are looking for.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by