如何更改多个freqz图的颜色?

时间:2015-04-04 17:26:37

标签: matlab plot matlab-figure

我正在使用" hold"在同一个地块上绘制多个频率响应。和" freqz"在MATLAB中。有没有办法调整每个情节的颜色,以便我可以确定哪一个是哪个?现在它看起来像一团糟。

enter image description here

Freqz似乎不支持改变情节的颜色,如"情节"确实

1 个答案:

答案 0 :(得分:3)

这确实有点棘手,因为freqz没有提供句柄。

b = fir1(80,0.5,kaiser(81,8));
freqz(b,1); hold on
c = fir1(80,0.9,kaiser(81,8));
freqz(c,1); hold on

但是你可以使用findall

来获取它们
lines = findall(gcf,'type','line');

然后像往常一样为线条着色:

lines(1).color = 'red'
lines(2).color = 'green'
lines(3).color = 'red'
lines(4).color = 'green'

或2014b之前的Matlab版本:

set(lines(1),'color','red')
set(lines(2),'color','green')
set(lines(3),'color','red')
set(lines(4),'color','green')

适用于所有LineSpec properties

enter image description here