3D Surf plot

5 vues (au cours des 30 derniers jours)
AbuYusuf
AbuYusuf le 25 Fév 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.

Réponse acceptée

Star Strider
Star Strider le 25 Fév 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.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by