3D Surf plot
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!