我绘制了六个衰减函数以及包含其幅度的曲线。我怎样才能使每个包络曲线(A)的颜色与它所包围的衰变函数(y)的颜色相匹配?
k = 1;
t = 0:0.1:10;
for R = 0:0.4:2;
y = exp(-(R/2).*t).*sin(k.*t);
A = exp(-(R/2).*t);
hold on
plot(t,y);
hold on
plot(t,A);
end
答案 0 :(得分:2)
获取默认颜色顺序,然后在绘制时循环显示每个颜色顺序。只要你没有超过最大默认颜色数7即可。
k = 1;
t = 0:0.1:10;
defColors = get(0,'defaultAxesColorOrder');
j = 1;
for R = 0:0.4:2;
y = exp(-(R/2).*t).*sin(k.*t);
A = exp(-(R/2).*t);
plot(t,y,'Color',defColors(j,:));
hold on
plot(t,A,'Color',defColors(j,:));
j = j+1;
end