Bode plot and cutoff frequency

346 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2016-11-26
编辑:Star Strider 2016-11-26
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 个评论
Star Strider
Star Strider 2016-11-26
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 2020-12-25
how can i plot magnetude , phase graph with cuttoff frequncy

请先登录,再进行评论。

更多回答(1 个)

zahypeti
zahypeti 2017-5-11
If you have the Control System Tlbx you can also try the bandwidth function.
fb = bandwidth(sys)
  1 个评论
Star Strider
Star Strider 2017-5-11
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Plot Customization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by