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
5 次查看(过去 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 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!