フィルターのクリア

Help with stem different colors

3 ビュー (過去 30 日間)
Christopher Carey
Christopher Carey 2017 年 12 月 3 日
コメント済み: Star Strider 2017 年 12 月 3 日
For my second plot my red lines keep coming up as red rings please help me with this clc; close all;
N=52;
x = zeros(1,N);
for n = 1:length(x)
x(n)= sin((n/16)*pi);
end
y= zeros(1,N);
y(1)=0;
for n = 2:length(x)-2
y(n+1)=(-1/3)*x(n+2)+(1/2)*x(n+1)+(1/3)*x(n)+y(n);
end
stem(0:1:51, y, 'r-');
xlabel('n');
ylabel('y[n]');
title('Output y[n] of the system');
pause;
z = conv(x,h);
stem(0:1:51, y, 'r-');
hold
stem(0:1:102, z, 'bo');
xlabel('n');
ylabel('z[n]');
title('z[n]');
legend('z[n]','y[n]');

採用された回答

Star Strider
Star Strider 2017 年 12 月 3 日
If you just want the vertical lines without the markers:
stem(0:1:51, y, 'r-', 'Marker','none')
If you want the markers solid colours:
stem(0:51, y, 'bo', 'filled')
  2 件のコメント
Christopher Carey
Christopher Carey 2017 年 12 月 3 日
Hey this is just making my red plot not display at all I'm just seeing the blue.
Star Strider
Star Strider 2017 年 12 月 3 日
You need to specify different figures. Using hold is appropriate for the second plot.
figure(1)
stem(0:1:51, y, 'r-');
xlabel('n');
ylabel('y[n]');
title('Output y[n] of the system');
pause;
z = conv(x,h);
figure(2)
stem(0:1:51, y, 'r-');
hold on
stem(0:1:102, z, 'bo')
hold off
xlabel('n');
ylabel('z[n]');
title('z[n]');
legend('z[n]','y[n]')
If you want them all in the same plot, put hold on after the first plot instead, and remove the figure(2) line.
I did not specifically test this part of your code. It should work.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by