Function Overview: Bode Plot Analysis with BodePlotA
The BodePlotA function is a robust tool designed to calculate and visualize the frequency response of a transfer function in the Laplace domain. It allows users to analyze how a system behaves across a specified range of frequencies, offering flexible options for plotting the Bode diagram and interacting with the data.
Inputs
- num (numerator coefficients): Coefficients of the transfer function's numerator.
- den (denominator coefficients): Coefficients of the transfer function's denominator.
- Alternatively, H (MATLAB Transfer Function Class): The transfer function can also be provided directly using MATLAB's tf class.
- fi (initial frequency in Hz): Starting frequency for the frequency response analysis.
- ff (final frequency in Hz): Ending frequency for the frequency response analysis.
- res (frequency resolution in Hz): Determines the granularity of the frequency response calculation.
- p (plot flag):
- 0: No Bode diagram is plotted.
- 1: The Bode diagram (magnitude and phase) is plotted.
- cursor (cursor flag, optional):
- 0: Cursor is disabled on the plot.
- 1: Cursor is enabled for detailed inspection.
Outputs
- F (frequency vector in Hz): A vector containing the frequencies used for the analysis.
- Gain (frequency response in dB): The magnitude response of the transfer function at each frequency.
- Phase (phase response in degrees): The phase of the transfer function at each frequency.
Example 1: Using num and den Coefficients MATLAB Code
wn = 2*pi*100; % Natural frequency in rad/s
xi = 0.707; % Damping ratio
num = [0 0 wn^2]; % Numerator coefficients
den = [1 2*xi*wn wn^2]; % Denominator coefficients
fi = 0.1; % Initial frequency (Hz)
ff = 10000; % Final frequency (Hz)
res = 0.1; % Frequency resolution (Hz)
[F, Gain, Phase] = BodePlotA(num, den, fi, ff, res, 1, 1);
Explanation
- System Definition:
- The system's natural frequency is set at 100 Hz, and the damping ratio is 0.707, which corresponds to a critically damped response.
- The transfer function is defined using the numerator num and denominator den coefficients.
- Frequency Range:
- The frequency response is computed from 0.1 Hz to 10,000 Hz, with a resolution of 0.1 Hz.
- Visualization:
- The plot flag p = 1 ensures that the Bode diagram is displayed.
- The cursor flag cursor = 1 enables interactive exploration of the plot.
Example 2: Using a Transfer Function Object MATLAB Code
wn = 2*pi*100; % Natural frequency in rad/s
xi = 0.707; % Damping ratio
num = [0 0 wn^2]; % Numerator coefficients
den = [1 2*xi*wn wn^2]; % Denominator coefficients
s = tf('s'); % Define the Laplace variable
H = (wn^2) / (s^2 + 2*xi*wn*s + wn^2); % Transfer function in MATLAB's tf format
fi = 0.1; % Initial frequency (Hz)
ff = 10000; % Final frequency (Hz)
res = 0.1; % Frequency resolution (Hz)
[F, Gain, Phase] = BodePlotA(H, fi, ff, res, 1, 1);
Explanation
- Transfer Function Object:
- The transfer function is defined directly using MATLAB's tf class as ( H(s) = \frac{\omega_n2}{s2 + 2\xi\omega_n s + \omega_n^2} ).
- Frequency Range and Resolution:
- Similar to Example 1, the frequency range is 0.1 Hz to 10,000 Hz, and the resolution is 0.1 Hz.
- Visualization and Interaction:
- The Bode diagram is plotted (p = 1), and the cursor is enabled (cursor = 1).
Practical Applications
These examples show how to use the BodePlotA function to analyze the frequency response of a system, either by specifying numerator and denominator coefficients or by using MATLAB's transfer function object. The flexibility of the function makes it a valuable tool in control systems, signal processing, and system dynamics analysis.
인용 양식
Márcio F. S. Barroso (2025). BodePlotA (https://www.mathworks.com/matlabcentral/fileexchange/<...>), MATLAB Central File Exchange. Retrieved March 6, 2025.
MATLAB 릴리스 호환 정보
개발 환경:
R2010b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!| 버전 | 게시됨 | 릴리스 정보 | |
|---|---|---|---|
| 1.0.4 | New function description |
|
|
| 1.0.2 | New function description |
|
|
| 1.0.1 | New Help |
|
|
| 1.0.0 |
