I have noted that sometimes state variables may change (thanks Thomas’s help :)), due to the Mathematica’s internal automatic transformation from a descriptor state-space model to a standard state-space model.
I think that the relationship x’ = a.x + b.u, y = c . x + d.u
should hold in any state-space.
However, this relationship doesn’t hold in the following state-space model.
Instead, I found that
x’ = a.x - b.u, y = - c . x + d.u
hold in my state-space model. Why does this happen?
By the way, I believe that I used the right state variable in my code.
code:
Remove["Global`*"] // Quiet;
m = {{Subscript[\[ScriptM], 1], 0, 0}, {0, Subscript[\[ScriptM], 2],
0}, {0, 0, Subscript[\[ScriptM], 3]}};
k = Array[Subscript[\[ScriptK], #1, #2] &, {3, 3}];
c = Array[Subscript[\[ScriptC], #1, #2] &, {3, 3}];
bs = {{1, -1, 0}, {0, 1, -1}, {0, 0, 1}};
\[CapitalLambda] = {{1, 1, 1}}\[Transpose];
uf = {uf1[t], uf2[t], uf3[t]};
ue = {ue1[t], ue2[t], ue3[t]};
pN = {pN1[t], pN2[t], pN3[t]};
mN = {mN1[t], mN2[t], mN3[t]};
u = Flatten@{uf, ue, pN, mN};
lhs = Flatten[
m.{x1''[t], x2''[t], x3''[t]} + c.{x1'[t], x2'[t], x3'[t]} +
k.{x1[t], x2[t], x3[t]}];
rhs = Flatten[+m.ue + bs.uf + m.\[CapitalLambda] pN];
eq = lhs - rhs == 0 // Thread;
y = {x1''[t], x2''[t], x3''[t]} + ue + mN;
z = {x3'[t], x3[t], x2'[t], x2[t], x1'[t], x1[t]};
ss = StateSpaceModel[eq, z, u, y, t,
SystemsModelLabels -> {ToString /@ u, ToString /@ y,
ToString /@ z}];
{AA, BB, CC, DD} = Normal[ss];
ddxEQ = Flatten[Solve[eq, {x3''[t], x2''[t], x1''[t]}]][[All, 2]];
ddxSS = (AA.z - BB.u)[[1 ;; -1 ;; 2]];
ddxEQ - ddxSS // Simplify
Reverse[ddxEQ] + ue + mN - Flatten[-CC.z + DD.u] // Simplify