Extract data from a bode plot.
38 views (last 30 days)
Show older comments
How do I extract an Excel table from the Bode of this transfer function:
format long;
s = tf('s');
HLM = ((2.524e-06)*s^3 + 37.11*s^2 + 37.6*s)/((2.704e-07)*s^3 + 1.767*s^2 + 41.36*s + 80);
Finf = 1e-3; %Hz
Fsup = 1e9; %Hz
options = bodeoptions;
options.FreqUnits = 'Hz';
Wmin = 2*pi*Finf;
Wmax = 2*pi*Fsup;
bode(HLM,{Wmin,Wmax}, options);
The bode was plotted in Hz, degrees, and from 1mHz to 1GHz.
0 Comments
Answers (1)
Star Strider
on 10 May 2022
Edited: Star Strider
on 10 May 2022
s = tf('s');
HLM = ((2.524e-06)*s^3 + 37.11*s^2 + 37.6*s)/((2.704e-07)*s^3 + 1.767*s^2 + 41.36*s + 80);
Finf = 1e-3; %Hz
Fsup = 1e9; %Hz
options = bodeoptions;
options.FreqUnits = 'Hz';
Wmin = 2*pi*Finf;
Wmax = 2*pi*Fsup;
figure
bode(HLM,{Wmin,Wmax}, options) % Plot With Options
[mag,phase,wout] = bode(HLM,{Wmin,Wmax}); % Return Calculated Data
mag = squeeze(mag);
phase = squeeze(phase);
fout = wout/(2*pi); % Convert To 'Hz'
BodeTable = table(fout,mag,phase)
EDIT — (10 May 2022 at 22:06)
Initially forgot that frequency vector was to be in Hz. Corrected.
.
4 Comments
Star Strider
on 11 May 2022
The frequency vector is an argument to the bode function (here ‘wv’) not the bodeoptions structure —
s = tf('s');
HLM = ((2.524e-06)*s^3 + 37.11*s^2 + 37.6*s)/((2.704e-07)*s^3 + 1.767*s^2 + 41.36*s + 80);
Finf = 1e-3; %Hz
Fsup = 1e9; %Hz
options = bodeoptions;
options.FreqUnits = 'Hz';
Wmin = 2*pi*Finf;
Wmax = 2*pi*Fsup;
wv = logspace(-3, 9, 1000)*2*pi; % Vector Of 500 Radian Frequencies (Logarithmically Scaled)
figure
bode(HLM, wv, options) % Plot With Options
[mag,phase,wout] = bode(HLM, wv); % Return Calculated Data
mag = squeeze(mag);
phase = squeeze(phase);
fout = wout/(2*pi); % Convert To 'Hz'
BodeTable = table(fout,mag,phase)
As requested, it produces a 1000-element frequency vector, and transfer function results at those values. (The plot does not appear to me to be different from the plot with the default frequencies, except for the higher frequency resolution.)
.
See Also
Categories
Find more on Plot Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
