3D Surf plot
5 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Star Strider
on 25 Feb 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.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!