フィルターのクリア

Why does the Bode function behaves differently in a subplot?

8 ビュー (過去 30 日間)
laszlo
laszlo 2014 年 12 月 15 日
コメント済み: laszlo 2015 年 1 月 6 日
Hi,
I want to run a script several times in a row, where every run new lines are plotted in a Bode diagram. This does not work when I use subplots, see the simple example below. Both lines are plotted this way, but the first line disappears when the 2 lines are uncommented and the example is rerun. So how can I plot these 2 lines in 1 Bode subplot? Thank you in advance!
Best regards, Laszlo
H = tf([1],[100]);
figure(100)
% subplot(2,1,1)
hold on
bodemag(H)
grid on
defcol
H = tf([1],[1 0 0]);
figure(100)
% subplot(2,1,1)
hold on
bodemag(H)
grid on
defcol

回答 (2 件)

Arkadiy Turevskiy
Arkadiy Turevskiy 2015 年 1 月 5 日
This works:
H = tf([1],[100]);
figure(100)
subplot(2,1,1);
[mag,ph,wout]=bode(H);
semilogx(wout,20*log10(squeeze(mag)));
grid on
xlabel('Frequency (rad/sec)');
ylabel('Magnitude (dB)');
title('Bode Diagram');
hold on;
H = tf([1],[1 1 0]);
figure(100)
subplot(2,1,1)
[mag,ph,wout]=bode(H);
semilogx(wout,20*log10(squeeze(mag)));
  1 件のコメント
laszlo
laszlo 2015 年 1 月 6 日
That works great. Thanks a lot!

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


Thorsten
Thorsten 2014 年 12 月 15 日
This litte script works for me; maybe something unexpected is going on in your bodemag function?
function plotdata(s)
figure(100)
subplot(2,1,1)
hold on
plot(1:10, s*rand(1,10), 'k')
grid on
figure(100)
subplot(2,1,1)
hold on
plot(1:10, s*rand(1,10), 'r')
grid on
  3 件のコメント
Thorsten
Thorsten 2014 年 12 月 15 日
I don't have the System Identification TB, so I have to ask if this works for you:
bodemag(gca, H)
laszlo
laszlo 2014 年 12 月 15 日
Too bad, that does not solve the problem.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by