Borrar filtros
Borrar filtros

How do I get all the plots to show over each other?

2 visualizaciones (últimos 30 días)
Girish Kolli
Girish Kolli el 24 de Mayo de 2018
Comentada: Rik el 27 de Mayo de 2018
I tried using 'hold on' and 'hold off' but don't know where to place it.
samplingfrequencies = [5, 7, 8, 9, 20];
colors = 'bgrcm';
i = 1;
for n = samplingFrequencies
t = 0 : (1 / n) : 5;
y = sin(8 * t * (2 * pi));
subplot(5,1,i);
h = plot(t,y,colors(i));
set(h,'marker','*')
axis([0, 5, -1, 1]);
title([num2str(n), 'Hz Sample Rate']);
xlabel('time');
ylabel('amplitude');
i = i+1;
end

Respuestas (1)

Rik
Rik el 24 de Mayo de 2018
Something like this maybe?
samplingfrequencies = [5, 7, 8, 9, 20];
colors = 'bgrcm';
i = 1;
for n = samplingFrequencies
t = 0 : (1 / n) : 5;
y = sin(8 * t * (2 * pi));
subplot(5,1,i);
hold on
h = plot(t,y,colors(i));
set(h,'marker','*')
axis([0, 5, -1, 1]);
title([num2str(n), 'Hz Sample Rate']);
xlabel('time');
ylabel('amplitude');
i = i+1;
end
hold off
  1 comentario
Rik
Rik el 27 de Mayo de 2018
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by