Writing titles and x/y labels inside a for loop and if-statements

18 vues (au cours des 30 derniers jours)
Cyrus Cruze
Cyrus Cruze le 17 Avr 2021
Commenté : Cyrus Cruze le 18 Avr 2021
I am ploting four different subplots and i am trying to title and label each axis of each subplot. The only one that gets titled and labled is the very last subplot. How might i fix this issue? See code and pictures.
F0 = 32100:125:32475;
for i = 1:1:4
FS = 8000;
f0=F0(i)/FS;
x = sin(2*pi*f0.*n + phi);
stem(n, x)
if (i == 1)
subplot(2,2,i)
stem(n, x)
title('Hz');
ylabel('[x(n)]');
xlabel('n');
elseif (i == 2)
subplot(2,2,i)
stem(n, x)
title('225Hz');
ylabel('[x(n)]');
xlabel('n');
elseif (i == 3)
subplot(2,2,i)
stem(n, x)
title('350Hz');
ylabel('[x(n)]');
xlabel('n');
elseif (i == 4)
subplot(2,2,i)
stem(n, x)
title('475Hz');
ylabel('[x(n)]');
xlabel('n');
end
end

Réponse acceptée

G A
G A le 17 Avr 2021
remove
stem(n, x)
before if statement

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by