bode() magnitude

49 ビュー (過去 30 日間)
aaa
aaa 2012 年 5 月 2 日
Hi, I Have seen the code [ mag,phase] = bode(sy s) but when i try to see the values of mag, or phase, it returns something like mag(:,:,1). What is the significance of the stuff in the brackets? How can i just get the magnitude values with respect to frequency so I can plot a 2d plot of the magnitude and frequency?
thanks

採用された回答

Arkadiy Turevskiy
Arkadiy Turevskiy 2012 年 5 月 2 日
Magnitude and phase outputs of bode are 3-D arrays, for representing multi-input multi-output systems. The first two dimensions correspond to the number of inputs and outputs, the third dimension corresponds to the number of frequency points. In your case you have a single-input single-output system, so size(mag) is 1 1 n, where n is the number of frequency points.
To get a standard bode plot you can just do
bode(sys)
If you want access to mag and phase as regular vectors, just do
mag=squeeze(mag)
All of this is covered in the doc.
Arkadiy

その他の回答 (4 件)

aaa
aaa 2012 年 5 月 2 日
hey thanks for your answer.
i have a followup question. what i did after. so i have
[mag,phase,wout] = bode(sys);
mag = squeeze(mag);
phase = squeeze(phase);
wout = squeeze(wout);
semilogx(wout,mag)
semilogx(wout,phase)
so when i plot the phase, i get the same result as i would doing bode(sys). The problem is when i plot the magnitude, the values on the y-axis are incorrect. I then added
mag = 20*log10(mag)
semilogx(wout,mag)
but it still appears to be incorrect. Can you provide some insight on maybe where i am going wrong?

Arkadiy Turevskiy
Arkadiy Turevskiy 2012 年 5 月 2 日
semilogx(wout,20*log10(squeeze(mag)))
gives you the same plot for magnitude as bode.
If it does not look the same, it is because the axes limits do not line up. You can customize that and other plot parameters to your liking as described here.

aaa
aaa 2012 年 5 月 2 日
i think i found out the problem. wout must be divided by 2pi to get the correct plot.

aaa
aaa 2012 年 5 月 2 日
SOrry as another question, I noticed that when you do
[mag, phase, wout] = bode(a)
it draws only about 45 points. Is there a way to get more?
Thanks
  1 件のコメント
Arkadiy Turevskiy
Arkadiy Turevskiy 2012 年 5 月 3 日
win=logspace(wout(1),wout(45),100);
% replace 100 with desired number of points
[mag,phase] = bode(sys,win);

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

カテゴリ

Help Center および File ExchangePlot Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by