3
我必须绘制一些Maclaurin系列,并且遇到与图例有关的问题。传说中的颜色与地块不匹配
对于这两个equations-
x = (-1:.01:1);
% e^x
eqtn21 = 1;
eqtn22 = 1 + x;
eqtn23 = 1 + x + x.^2/2;
eqtn24 = 1 + x + x.^2/2 + x.^3/6;
eqtn25 = exp(x);
% cos(x)
eqtn31 = 1;
eqtn32 = 1 - x.^2/2;
eqtn33 = 1 - x.^2/2 + x.^4/24;
eqtn34 = 1 - x.^2/2 + x.^4/24 - x.^6/720;
eqtn35 = cos(x);
subplot(2,2,1)
plot(x,eqtn21,'r',x,eqtn22,'g',x,eqtn23,'b',x,eqtn24,'k',x,eqtn25,'c')
legend('First Term','First Two Terms','First Three Terms','First Four Terms','Exact Function')
subplot(2,2,2)
plot(x,eqtn31,'r',x,eqtn32,'g',x,eqtn33,'b',x,eqtn34,'k',x,eqtn35,'c')
legend('First Term','First Two Terms','First Three Terms','First Four Terms','Exact Function')
当我绘制出来,传说显示出来,但显示5条红线和剧情不匹配的颜色。
这是有道理的,谢谢你的帮助 – 2014-09-23 20:17:02
容易peasy ... :) – bla 2014-09-23 20:17:59