Bode plot and cutoff frequency
127 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Aaron Connell
il 25 Nov 2016
Commentato: Anish Mitra
circa 12 ore fa
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
0 Commenti
Risposta accettata
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.
4 Commenti
Anish Mitra
circa 12 ore fa
The markers for the -3dB point can be plotted on a "bodeplot". Beginning in R2025a, the chart object has a DataAxes property that can be used to specify the axes on which you would like to add markers or lines.
From code above :
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
Create a bodeplot and add markers.
bp = bodeplot(Transfer_Function);
bp.NextPlot = "add"; % Commands like semilogx will add the markers to the existing axes
bp.AxesStyle.GridVisible = "on";
bp.DataAxes = [1 1]; % Markers will be added to the top axes (magnitude)
semilogx(dB3(1),20*log10(dB3(3)),SeriesIndex=2,Marker='+',MarkerSize=10);
bp.DataAxes = [2 1];
semilogx(dB3(1),dB3(2),SeriesIndex=2,Marker='+',MarkerSize=10);
Più risposte (1)
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
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.
Vedere anche
Categorie
Scopri di più su Time and Frequency Domain Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!