Bode Plots: viewing values at a particular point
55 views (last 30 days)
Show older comments
How do I find the intercepts of the axes? and how do I find a value at a particular point? (eg. finding the frequency when magnitude=3db)
0 Comments
Answers (1)
Star Strider
on 30 Apr 2017
The Control System Toolbox bandwidth function will work in some situations, but in others it’s necessary to take a less direct approach to calculate the -3 dB points.
Example —
s = tf('s');
sys = s^2/(s^3 - 2*s^2 - 2*s + 5);
[mag, phase, wout] = bode(sys);
mag = squeeze(mag);
phase = squeeze(phase);
mag_max = max(mag);
dB_3 = 10^(-3/20)*mag_max;
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
zx = zci(mag-dB_3);
for k1 = 1:length(zx)
dB3w(k1) = interp1(mag(zx(k1):zx(k1)+1), wout(zx(k1):zx(k1)+1), dB_3, 'linear','extrap');
dB3p(k1) = interp1(wout(zx(k1):zx(k1)+1), phase(zx(k1):zx(k1)+1), dB3w(k1), 'linear','extrap');
end
figure(1)
subplot(2,1,1)
plot(wout, 20*log10(mag))
hold on
plot(dB3w, 20*log10([1 1]*dB_3), 'pg')
hold off
xlabel('Frequency')
ylabel('Amplitude (dB)')
grid
subplot(2,1,2)
plot(wout, phase)
hold on
plot(dB3w, dB3p, 'pg')
hold off
xlabel('Frequency')
ylabel('Phase')
grid
The ‘dB3w’ array are the frequencies of the -3 dB points, and ‘dB3p’ are the phase values at those frequencies.
I’m not certain what you mean by ‘the intercepts of the axes’. Those would seem to be the beginning and end elements of the vectors, so ‘wout(1)’ and ‘wout(end)’, and so for the others.
4 Comments
Star Strider
on 1 May 2017
My pleasure.
If my Answer helped you solve your problem, please Accept it!
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!