Does changing the model representation preserve the response?

English translation

Control Engineering I · Week 7

This week's goal · Verify state space, transfer functions, and state coordinate transformations through input–output responses.

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.

1. Check matrix dimensions before transforming

First check matrix dimensions in 𝐱̇=A𝐱+Bu\dot{\mathbf x}=A\mathbf x+B u and y=C𝐱+Duy=C\mathbf x+D u. With 2 states, 1 input, and 1 output, A:2×2, B:2×1, C:1×2, D:1×1. Ax and Bu must each produce as many values as there are states, and Cx and Du as many as there are outputs, so that the respective terms can be added.

Check matrix dimensions before transforming

Even with the same A and B, observing position and observing velocity give different outputs. Check which state C selects. This model uses x=[position;velocity] and C=[1,0]C=[1,0] as the baseline.

2. Different representations of the same model

G(s)=C(sI−A)−1B+DG(s)=C(sI-A)^{-1}B+D is the input–output relationship with all initial conditions equal to 0. Compare tf(ss(A,B,C,D)) with the state-space step response using the same time axis. Numerically check whether the output difference is small.

Different representations of the same model

Converting to a transfer function hides the names of internal states and initial-state information. Equal step responses do not imply identical internal information.

3. Changing coordinates changes the matrices

𝐱=P𝐳\mathbf x=P\mathbf z expresses the same state in differently scaled coordinates. Substituting it into 𝐱̇=A𝐱+Bu\dot{\mathbf x}=A\mathbf x+B u gives P𝐳̇=AP𝐳+BuP\dot{\mathbf z}=AP\mathbf z+Bu. Multiplying both sides by P⁻¹ gives 𝐳̇=(P−1AP)𝐳+(P−1B)u\dot{\mathbf z}=(P^{-1}AP)\mathbf z+(P^{-1}B)u, hence Az=P−1AP,Bz=P−1BA_z=P^{-1}AP,\quad B_z=P^{-1}B. Substituting 𝐱=P𝐳\mathbf x=P\mathbf z into the output equation y=C𝐱y=C\mathbf x gives y=CP𝐳y=CP\mathbf z, hence Cz=CPC_z=CP. Rescale the states using P=diag⁡(2,0.5)P=\operatorname{diag}(2,0.5). In MATLAB, you can calculate with P\(A*P) instead of inv(P)*A*P.

Changing coordinates changes the matrices

P must be invertible to convert between the new and original coordinates in both directions. The initial state must also be changed to z0=P\x0 to represent the same motion.

4. Find errors by comparing responses before and after transformation

If the step responses match but the initial-state responses differ, first check the initial-value coordinates. Check the input, time axis, output, and initial values in order.

Find errors by comparing responses before and after transformation

Change one code line yourself to reproduce an error caused by omitting the initial-value transformation, then correct it. To represent the same motion after changing coordinates, change both the model matrices and the initial values.

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