考虑下图:
在左侧,您可以使用patch
命令看到相对于函数轮廓的圆的填充
t = linspace(-pi,pi,100);
c = exp(-cos(t));
figure(1)
patch(cos(t),sin(t),c)
axis equal
在右侧,您可以看到沿左侧虚线轴的函数轮廓,该轮廓是使用area
命令填充的。
figure(2)
area(cos(t),c,0);
我正在尝试做的是用左面板中表示的颜色映射表定义的颜色填充曲线(右面板)下的区域。结果应该如下所示
发布于 2019-03-24 12:55:52
我能想到的最接近的东西是:
function q55322965
% Evaluate the equation (half domain!)
t = linspace(-pi,0,50);
c = exp(-cos(t));
% Turn vectors into a mesh:
[TT,CC] = meshgrid(cos(t),c);
% Clear all points that are above the curve:
CC(CC > c) = NaN;
% Fill in the rectangle between the chart and zero:
CC(end+1,:) = 0;
TT(end+1,:) = TT(end,:);
% Plot:
figure(); mesh(TT,CC,CC,'FaceColor','interp','EdgeColor','interp'); view([0,90]);
这会产生以下结果:
如果要在使用此方法打印时减少锯齿,可以在t
中提高分辨率。例如,如果我们在linspace
中使用500
而不是50
,我们会得到:
https://stackoverflow.com/questions/55322965
复制相似问题