3D Surf plot

5 visualizaciones (últimos 30 días)
AbuYusuf
AbuYusuf el 25 de Feb. de 2017
Respondida: Star Strider el 25 de Feb. de 2017
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.

Respuesta aceptada

Star Strider
Star Strider el 25 de Feb. de 2017
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.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by