필터 지우기
필터 지우기

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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by