Bode Plot Analysis with BodePlotA

バージョン 1.0.4 (25.5 KB) 作成者: Márcio
Plot the Bode Diagram
ダウンロード: 9
更新 2025/3/28

ライセンスの表示

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
  1. num (numerator coefficients): Coefficients of the transfer function's numerator.
  2. den (denominator coefficients): Coefficients of the transfer function's denominator.
  3. Alternatively, H (MATLAB Transfer Function Class): The transfer function can also be provided directly using MATLAB's tf class.
  4. fi (initial frequency in Hz): Starting frequency for the frequency response analysis.
  5. ff (final frequency in Hz): Ending frequency for the frequency response analysis.
  6. res (frequency resolution in Hz): Determines the granularity of the frequency response calculation.
  7. p (plot flag):
  • 0: No Bode diagram is plotted.
  • 1: The Bode diagram (magnitude and phase) is plotted.
  1. cursor (cursor flag, optional):
  • 0: Cursor is disabled on the plot.
  • 1: Cursor is enabled for detailed inspection.
Outputs
  1. F (frequency vector in Hz): A vector containing the frequencies used for the analysis.
  2. Gain (frequency response in dB): The magnitude response of the transfer function at each frequency.
  3. 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
  1. 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.
  1. Frequency Range:
  • The frequency response is computed from 0.1 Hz to 10,000 Hz, with a resolution of 0.1 Hz.
  1. 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
  1. 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} ).
  1. 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.
  1. 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
バージョン 公開済み リリース ノート
1.0.4

New function description

1.0.2

New function description

1.0.1

New Help

1.0.0