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

18 ビュー (過去 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
  1 件のコメント
Cyrus Cruze
Cyrus Cruze 2021 年 4 月 18 日
wow. i feel really silly now. Thank you ha

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by