【发布时间】:2015-01-02 01:29:46
【问题描述】:
我一直试图在 Matlab 中绘制一些不等式。
当它在 Matlab 图中显示时,它看起来是正确的:
但是当我保存图形时,我得到了这条烦人的黄线(手动保存和代码保存时):
产生情节的代码是:
function [ ] = plotInequalities( ~ )
pRange = linspace(1/2,1,1000);
cRange = linspace(0,1,1000);
[P, C] = meshgrid(pRange,cRange);
ineq1 = P >= 2/3;
ineq2 = C.*P.*(3-4.*P)./(2.*P+C.*(2-4.*P)) >= 1-P;
ineq3 = C <= 3.*P.*(1-P)./(2.*(-6.*P.^2+6.*P-1));
rest = ~ineq1 & ~ineq2 & ~ineq3;
pl = figure
hold on
c = 2:5;
contourf(pRange, cRange, c(2) * ineq2, [c(2), c(2)], 'c')
contourf(pRange, cRange, c(3) * ineq3, [c(3), c(3)], 'y')
contourf(pRange, cRange, c(4) * rest, [c(4), c(4)], 'r')
contourf(pRange, cRange, c(1) * ineq1, [c(1), c(1)], 'b')
legend('\{A,AB\}', '\{A,B\}', '\{A,AB, B\}', '\{A\}')
xlabel('P')
ylabel('C')
saveas(pl, 'out.png','png');
end
我在 Windows 8 上使用 Matlab R2014a。
知道为什么会发生这种情况吗?
【问题讨论】:
-
请提供更多细节。显示您用于生成绘图的代码,并保存图形(哪种格式?)。了解哪个版本的 matlab(和平台)也可能有用。
-
@Hoki - 感谢您的评论。添加了详细信息。