Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
Girish Kolli
Girish Kolli il 24 Mag 2018
Commentato: Rik il 27 Mag 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

Risposte (1)

Rik
Rik il 24 Mag 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 Commento
Rik
Rik il 27 Mag 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.

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by