如何用surf()函数,用u和v两个变量的参数方程,在MATLAB中绘制椭圆抛物面?方程看起来就像
r = {ucos{v}, u^2,5usin{v}}我知道我需要用u和v构建网格,但是接下来怎么办?
发布于 2015-10-17 20:13:24
你可以这样做:
%// 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中的新手。
https://stackoverflow.com/questions/33187263
复制相似问题