Connect transfer functions and blocks

English translation

Control Engineering I · Week 4

This week's goal · Represent the same input–output relationship using equations and Simulink blocks.

Run: After signing in to MathWorks, open .mlx in your workspace. Click inside the code → Live Editor → Run Section to run one section at a time. Run runs everything. After changing a value, rerun the relevant section. Edit the text in ⟦enter here⟧ response fields; do not execute them. You can use Ctrl+Enter on Windows/Linux and ⌘+Enter on Mac.

Decide what to include in the model

Conceptual example · Compare constant-velocity motion with spring motion to explain how to choose a model. The model to implement in this exercise is the mass–spring–damper below.

Constant-velocity motion ignores velocity changes, and constant-acceleration motion assumes constant acceleration. Both are useful models under conditions appropriate to their purpose. As with the motion assumptions in week 2, first decide which changes you intend to describe.

A constant-velocity model may suffice to estimate distance traveled briefly. To describe how a spring-connected object oscillates and stops after a force is applied, include forces that depend on position and velocity. Details of component structure with little effect on this behavior may be omitted.

This exercise expresses the existing mass–spring–damper model as a transfer function and Simulink blocks. Changing the representation differs from adding physical effects. The same model with the same input and initial conditions should give the same response.

When to refine the model

Refine the model if prediction–measurement differences exceed the tolerance for your purpose and arise from omitted effects. For example, actuator delay may matter in fast motion. Adding more terms is not itself the goal. First check the units, coefficients, input, and initial conditions.

1. Transfer functions have conditions

Transforming the mass–spring–damper equation Mÿ+bẏ+ky=uM\ddot y+b\dot y+ky=u with all initial conditions equal to 0 gives G(s)=YU=1Ms2+bs+kG(s)=\frac YU=\frac1{Ms^2+bs+k}. Changing the input force or output displacement gives a different transfer function.

Transfer functions have conditions

A transfer function describes how the input changes the output when all initial conditions are 0, such as applying force to an object initially at rest at equilibrium. If the object starts elsewhere or is already moving, calculate that effect separately in addition to G(s)U(s).

2. Reading coefficient arrays

The denominator of tf([1],[1 2 5]) is s²+2s+5. Write coefficients in descending powers, inserting 0 for any missing intermediate power to retain its position. Three coefficients correspond to s², s, and the constant term. For example, write s²+5 as [1 0 5].

Order of the coefficient array

MATLAB's * and .* differ. Use .*, .^, and ./ for calculations between corresponding array elements, and express matrix relations with *.

3. Check the feedback sign

With negative feedback, y=G(r−Hyr-Hy), so T=G1+GHT=\frac G{1+GH}. feedback(G,H) constructs this relation by default. For H=1, check whether the denominator's constant term changes from 5 to 6.

Check the feedback sign

Physical feedback requires the output and comparison signal to have matching units. The H=1 example assumes the measurement equals the output. If a real sensor converts velocity to voltage, the reference must also be converted to the same voltage units for comparison.

4. The same model in Simulink

Connect Step → Transfer Fcn → Scope, and set numerator [1] and denominator [1 2 5]. Match the input timing, amplitude, and simulation duration to the MATLAB code, then compare the responses.

The same model in Simulink

Open the accompanying .slx file and run the model. In the assignment, check the blocks' roles and coefficients and modify your copy. If no signal appears in Scope, check the wire connections and Step time first.

Check your understanding

  1. What values should go into the code, and what does each row and column of the resulting array represent? If calculating physical quantities, have you also checked the units?
  2. Can you identify which parts to rerun when you change one condition?
  3. Do the results match your expectations? If they differ, can you explain why using the output values or plots?

Official MATLAB documentation · Control System Toolbox

Practice materials