Help with stem different colors
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Christopher Carey
el 3 de Dic. de 2017
Comentada: Star Strider
el 3 de Dic. de 2017
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]');
0 comentarios
Respuesta aceptada
Star Strider
el 3 de Dic. de 2017
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 comentarios
Star Strider
el 3 de Dic. de 2017
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!