Bode Plots: viewing values at a particular point

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)

Answers (1)

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

That seems like a very lengthy process given that i have already managed to plot it by defining the transfer function and using bode()
Plotting it using bode is easy. If you only have one -3 dB point and your transfer function is behaving nicely (monotonically decreasing from the d-c amplitude), you can use the bandwidth function, as I mentioned.
If you have a more complicated transfer function, such as I illustrated here, bandwidth won’t work, and it’s necessary to do a more exhaustive search and estimation. I decided to create reasonably robust code since I don’t know the transfer function you’re working with.
Note that the bode plot is not like other plot functions, such as the Signal Processing Toolbox freqs or freqz functions that plot the same information for filters, and are simple subplot plots. Explore them to see the differences.
My code here is likely the most efficient way to do what you want.
Ahh makes sense, thanks :)
My pleasure.
If my Answer helped you solve your problem, please Accept it!

Sign in to comment.

Asked:

on 30 Apr 2017

Commented:

on 1 May 2017

Community Treasure Hunt

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

Start Hunting!