Course materials · Control Engineering II
Programming language

Frequency Response

English translation

Understanding how amplitude and phase change at each frequency connects Bode plots to actual signals.

Before practice

01 What aspect of the output does Bode gain describe?

Description

It is the ratio of steady-state output amplitude to input amplitude at the same frequency.

02 How does a remaining transient affect phase estimation?

Description

Mixing the steady-state sinusoid with the transient introduces amplitude and phase estimation errors.

Execution conditions

Read magnitude and phase from python-control's ctl.frequency_response. Phase is returned in radians; convert it to degrees in the table.

If the module is missing, run %pip install control==0.10.2 in a Colab or Jupyter code cell.

MATLAB · Control System Toolbox

Practice

Preview practice notebookDownload practice notebookPreview practice mlx scriptDownload practice mlx script

1. Measuring gain and phase with sinusoids

Starting conditions

G(s)=1s2+0.5s+1G(s)=\frac1{s^2+0.5s+1}, u=sin⁡(ωt)u=\sin(\omega t), ω∈{.2,1,3}\omega\in\{.2,1,3\} rad/s. 0≤t≤2000\le t\le 200 s, Δt=.01\Delta t=.01 s.

Procedure

  1. Calculate the output using ctl.forced_response, andcalculate the output using lsim, then plot the input and output for only the final two periods.
  2. Fit the output to asin⁡(ωt)+bcos⁡(ωt)a\sin(\omega t)+b\cos(\omega t) by least squares to obtain gain a2+b2\sqrt{a^2+b^2} and phase atan2⁡(b,a)\operatorname{atan2}(b,a).
  3. Compare with the magnitude and phase from ctl.frequency_response. Phase is returned in radians.Compare with the gain and phase calculated using abs and angle from the complex response of squeeze(freqresp(G,omega)). angle returns radians. Convert both phase calculations to degrees in the table.

Results to retain

Items to record and points to check
ω [rad/s]
Measured gain
Calculated gain
Measured phase [deg]
Calculated phase [deg]

Points to check

  • Did you exclude the initial interval containing the transient?
  • Did you compare errors after aligning phase units and accounting for 360° periodicity?

2. Comparing damping and resonance

Starting conditions

Set the denominator to s2+as+1s^2+as+1 and compare a∈{.2,.5,1}a\in\{.2,.5,1\}. Use ω=logspace(-2,2,400).

Procedure

  1. Plot the gains and phases of the three models on the same frequency axis.
  2. Tabulate each model's maximum gain, its frequency, and DC gain.
  3. Choose one sinusoidal condition near the maximum gain and check it using the method from the first activity.

Results to retain

Items to record and points to check
a
Maximum gain
ω at maximum gain
DC Gain

Points to check

  • Did you distinguish dB from linear gain?
  • Did you use the same frequency grid and input amplitude for all models?

3. Checking frequency units in the time domain

Starting conditions

ω=1\omega=1 rad/s differs from f=1f=1 Hz. The second input is sin⁡(2πt)\sin(2\pi t).

Procedure

  1. First record the periods of both inputs, then calculate their responses for the same G.
  2. Record the phase difference both as a time delay and as an angle.
  3. Explain what you would misread on a Bode plot if you confused rad/s with Hz.

Results to retain

Items to record and points to check
Input
ω [rad/s]
Period [s]
Gain
Phase [deg]

Points to check

  • Did you use the relationship T=2πωT=\frac{2\pi}{\omega}?
  • Did you record amplitude changes and period changes as distinct phenomena?