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
3 ビュー (過去 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
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Geographic Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!