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

조회 수: 16 (최근 30일)
Cyrus Cruze
Cyrus Cruze 2021년 4월 17일
댓글: Cyrus Cruze 2021년 4월 18일
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

채택된 답변

G A
G A 2021년 4월 17일
remove
stem(n, x)
before if statement

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by