Bode plot and cutoff frequency

403 visualizzazioni (ultimi 30 giorni)
Aaron Connell
Aaron Connell il 25 Nov 2016
Commentato: suketu vaidya il 25 Dic 2020
below I am creating a bode plot of the specified transfer function. I want to know if there is an option using bode plot options to mark the corner frequency on the plot and determine the magnitude and phase at that frequency. How would I go about doing this on the plot
% code
num=[1]; %set the numerator in a matrix
den=[1 1.5]; %set the denominator in a matrix
Transfer_Function=tf(num,den) % use the tf function to set the transfer function
bodeplot(Transfer_Function) %create a bode plot
grid

Risposta accettata

Star Strider
Star Strider il 26 Nov 2016
Modificato: Star Strider il 26 Nov 2016
Unfortunately, while bodeplot can do much, for whatever reason, it’s not possible to overplot anything on it. A somewhat more primitive approach is necessary:
num=[1]; %set the numerator in a matrix
den=[1 1.5]; %set the denominator in a matrix
Transfer_Function=tf(num,den) % use the tf function to set the transfer function
[mag,phase,wout] = bode(Transfer_Function); % Get Plot Data
mag = squeeze(mag); % Reduce (1x1xN) Matrix To (1xN)
phase= squeeze(phase);
magr2 = (mag/max(mag)).^2; % Calculate Power Of Ratio Of ‘mag/max(mag)’
dB3 = interp1(magr2, [wout phase mag], 0.5, 'spline'); % Find Frequency & Phase & Amplitude of Half-Power (-3 dB) Point
figure(1)
subplot(2,1,1)
semilogx(wout, 20*log10(mag), '-b', dB3(1), 20*log10(dB3(3)), '+r', 'MarkerSize',10)
grid
subplot(2,1,2)
semilogx(wout, phase, '-b', dB3(1), dB3(2), '+r', 'MarkerSize',10)
grid
EDIT
The code I added takes the data created by the bode function (magnitude, phase and radian frequency respectively) and first uses interpolation to calculate the half-power point values of all three variables. The half-power point (or -3 dB point) is defined as half the value of the square of the normalised ratio of the magnitude. This is the ‘magr2’ (magnitude ratio squared) vector.
Since the ‘breakpoint’ or the ‘passband’ is defined as the half-power point, the interp1 call uses ‘magr2’ as the independent variable for the spline interpolation to approximate the value corresponding to the half-power value for the frequency, phase, and magnitude matrix [wout phase mag]. (There’s nothing magic about using the spline interpolation, and here a linear interpolation would likely be as accurate.) This magickally returns those corresponding values in the ‘dB3’ vector (corresponding to the -3 dB point). These are the radian frequency, phase, and magnitude for the half-power point, respectively, as requested. These interpolated values are then overplotted as ‘+’ on the transfer function magnitude and phase plots.
The plots are then straightforward to understand. In order to make them compatible with the bode plot format, I plotted the magnitude and marker as a decibel 20*log10() values. (For magnitudes, the 20 multiplier is used, for power a 10 multiplier is used.)
Parenthetically, the Signal Processing Toolbox freqz and freqs create regular subplots that it is possible to address directly. The Control System Toolbox (and related Toolboxes) apparently have their own formats, so it is necessary to take the ‘long way round’ here.
  3 Commenti
Star Strider
Star Strider il 26 Nov 2016
My pleasure.
There’s not room to adequately describe the code in comments in the code (although I commented many lines with brief descriptions). I instead opted to add a few descriptive paragraphs explaining the rationale behind my code and how it works. I made it as straightforward as I can, and if it still lacks clarity, I’ll add more explanation as necessary.
The key idea is that transfer functions (and may other aspects of electrical engineering) are described in terms of power, not magnitude. This is one such situation. So for example a half-power point is defined as -3 dB, and the corresponding point with respect to magnitude is -6 dB. It’s easier to calculate the half-power point (the -3 dB point) from the power vector.
suketu vaidya
suketu vaidya il 25 Dic 2020
how can i plot magnetude , phase graph with cuttoff frequncy

Accedi per commentare.

Più risposte (1)

zahypeti
zahypeti il 11 Mag 2017
If you have the Control System Tlbx you can also try the bandwidth function.
fb = bandwidth(sys)
  1 Commento
Star Strider
Star Strider il 11 Mag 2017
True, however the bandwidth function only works if the amplitude is monotonically decreasing from the d-c (or 0 Hz) amplitude. It will not work in other situations.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by