Borrar filtros
Borrar filtros

Help with stem different colors

3 visualizaciones (últimos 30 días)
Christopher Carey
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]');

Respuesta aceptada

Star Strider
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
Christopher Carey
Christopher Carey el 3 de Dic. de 2017
Hey this is just making my red plot not display at all I'm just seeing the blue.
Star Strider
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh 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!

Translated by