0
我如何可以绘制在MATLAB椭圆抛物面与surf()
功能,采用参数方程有两个变量ü和v?公式看起来像绘制椭圆抛物面在MATLAB
r = {ucos{v}, u^2,5usin{v}}
我明白,我需要从ü和v做出meshgrid,但下一步怎么办?
我如何可以绘制在MATLAB椭圆抛物面与surf()
功能,采用参数方程有两个变量ü和v?公式看起来像绘制椭圆抛物面在MATLAB
r = {ucos{v}, u^2,5usin{v}}
我明白,我需要从ü和v做出meshgrid,但下一步怎么办?
你可以做到这一点通过以下方式:
%// 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的。
thx,这是非常有帮助的) – blitzar787