2015-10-17 418 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