如何使用surf()
函数在MATLAB中绘制椭圆抛物面,使用2个变量 u 和 v 的参数方程?等式看起来像
r = {ucos{v}, u^2,5usin{v}}
我知道我需要从你和 v 制作网格网格,但下一步该做什么?
答案 0 :(得分: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的新手。