3D Surf plot

3 ビュー (過去 30 日間)
AbuYusuf
AbuYusuf 2017 年 2 月 25 日
回答済み: Star Strider 2017 年 2 月 25 日
I am expecting to see 3D surface, but I think I have problem creating the mesh or something, would any one help wih this?
N=100000;
x = linspace(1e3,10e6,N) ;
y = linspace(100e-9,10e-3,N) ;
z = 5.*x + sqrt (1./(y.*x).^2 + 1000);
surf(x,y,z);
always I am getting z should be matrix not vector or scalar? if surf only deals with matrices, how can I plot z in 3D and surface shape? I already have it as a line in 3D using plot3 command.

採用された回答

Star Strider
Star Strider 2017 年 2 月 25 日
You need to create the matrices with the meshgrid function:
N=1000; % Reduce Number Of Points
x = linspace(1e3,10e6,N) ;
y = linspace(100e-9,10e-3,N) ;
[X,Y] = meshgrid(x,y); % Use ‘meshgrid’
z = @(x,y) 5.*x + sqrt (1./(y.*x).^2 + 1000); % Convert To Anonymous Function
meshc(x,y,z(X,Y));
I converted ‘z’ to an anonymous function for simplicity.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by