Converting differential equations to State-Space/Transfer Function representation

147 views (last 30 days)
Bruno Silva on 23 Nov 2021
Commented: Bruno Silva on 24 Nov 2021
I'm trying to solve some Control Systems questions, but having trouble with a few of them: Basically, the question asks for the state-space representation of each system.
I used odeToVectorField for systems a and b:
syms y(t) u(t) t
yd = diff(y);
ydd = diff(y, 2);
yddd = diff(y, 3);
EQD = ydd + 3*yd + y == u
EQD(t) = [SS, Sbs] = odeToVectorField(EQD)
SS = Sbs = EQD2 = yddd + 5*ydd + 8*yd + 12*y == u
EQD2(t) = [SS2, Sbs2] = odeToVectorField(EQD2)
SS2 = Sbs2 = from which I can get the state-space representation.
But when I get to the other systems (for example, system f), it gets trickier, and most of the systems can't even be solved using odeToVectorField.
syms y(t) u(t) t
yd = diff(y);
ydd = diff(y, 2);
yddd = diff(y, 3);
yi = int(y, 0, t);
ud = diff(u);
EQD = ydd + 2*yd + y + yi == ud + 5*u
EQD(t) = [SS, Sbs] = odeToVectorField(EQD)
Number of indeterminates exceeds the number of ODEs.

T = feval_internal(symengine,'symobj::odeToVectorField',sys,x,stringInput);

Error in odeToVectorField (line 119)
Is there an easier way to get the state-space representation (or transfer function) directly from the differential equations? And how can I do the same for the more complex differential equations (like f and g, for example)?
Thank you

Paul on 23 Nov 2021
Edited: Paul on 23 Nov 2021
There really is no need to use the symbolic stuff (though you can if you really want, at least for part of the problem). Suppose Z(s) is the Laplace transform of z(t). You just need know how to express the Laplace transform of dz(t)/dt and integral(z(t)) (using bad notation) in terms of Z(s). You will find these relationships in your class notes or text book or any number of on line sources. Once you know how to do that, you'll be able to solve each of those equations for the ratio Y(s)/U(s). At that point you can use ss() to find a (not "the") state space representation.
For example, suppose you found: Y(s)/U(s) = (2s + 1)/(s^2 + s + 2). You can find a state space model as
ss(tf([2 1],[1 1 2]))
ans = A = x1 x2 x1 -1 -2 x2 1 0 B = u1 x1 2 x2 0 C = x1 x2 y1 1 0.5 D = u1 y1 0 Continuous-time state-space model.
But you'll have to find Y(s)/U(s) first.
Problem g is trickier. There you'll have to find the matrix M(s) such that [Y1(s);Y2(s)] = M(s)*[U1(s);U2(s), then express M as a tf object, and then use ss(M).
Bruno Silva on 24 Nov 2021
Thank you very much for your help.

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!