2015-10-17 136 views
0

我如何可以繪製在MATLAB橢圓拋物面與surf()功能,採用參數方程有兩個變量üv?公式看起來像繪製橢圓拋物面在MATLAB

r = {ucos{v}, u^2,5usin{v}} 

我明白,我需要從üv做出meshgrid,但下一步怎麼辦?

回答

1

你可以做到這一點通過以下方式:

%// Create three function handles with the components of you function 
fx = @(u,v) u.* cos(v); %// Notice that we use .* 
fy = @(u,v) u.^2;  %// and .^ because we want to apply 
fz = @(u,v) 5.*u.*sin(v);%// multiplication and power component-wise. 

%// Create vectors u and v within some range with 100 points each 
u = linspace(-10,10, 100); 
v = linspace(-pi,pi, 100); 

%// Create a meshgrid from these ranges 
[uu,vv] = meshgrid(u, v); 

%// Create the surface plot using surf 
surf(fx(uu,vv), fy(uu,vv), fz(uu,vv)); 

%// Optional: Interpolate the color and do not show the grid lines 
shading interp; 

%// Optional: Set the aspect ratio of the axes to 1:1:1 so proportions 
%//   are displayed correctly. 
axis equal; 

我加了一些註釋,因爲你似乎是新的Matlab的。

+0

thx,這是非常有幫助的) – blitzar787