Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Girish Kolli
Girish Kolli am 24 Mai 2018
Kommentiert: Rik am 27 Mai 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

Antworten (1)

Rik
Rik am 24 Mai 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 Kommentar
Rik
Rik am 27 Mai 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by