Converting differential equations to State-Space/Transfer Function representation

376 vues (au cours des 30 derniers jours)
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)
Error using mupadengine/feval_internal
Number of indeterminates exceeds the number of ODEs.

Error in odeToVectorField>mupadOdeToVectorField (line 171)
T = feval_internal(symengine,'symobj::odeToVectorField',sys,x,stringInput);

Error in odeToVectorField (line 119)
sol = mupadOdeToVectorField(varargin);
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

Réponse acceptée

Paul
Paul le 23 Nov 2021
Modifié(e) : Paul le 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).
  5 commentaires
Paul
Paul le 24 Nov 2021
Here you go
syms y(t) u(t) tau
eqn = diff(y(t),t,2)+2*diff(y(t),t) + y + int(y(tau),tau,0,t) == diff(u(t),t) + 5*u(t)
eqn(t) = 
Leqn = laplace(eqn)
Leqn = 
syms Dy0
Leqn = subs(Leqn,subs(diff(y(t), t), t, 0),Dy0)
Leqn = 
Leqn = subs(Leqn,[y(0) Dy0 u(0)],[0 0 0])
Leqn = 
syms Y U s
Leqn = subs(Leqn,[laplace(y(t),t,s) laplace(u(t),t,s)],[Y U])
Leqn = 
Y = solve(Leqn,Y)
Y = 
H(s) = Y/U
H(s) = 
H = simplify(H)
H(s) = 
Bruno Silva
Bruno Silva le 24 Nov 2021
Thank you very much for your help.

Connectez-vous pour commenter.

Plus de réponses (1)

Samim Unlusoy
Samim Unlusoy le 22 Déc 2022
The following approach may be useful. State equations for the classical ordinary matrix differential equations
[M]{yddot} + [C]{ydot} + [K]{y} = [F]{q}
are given by:
[0] [I] [0]
{xdot} = [A]{x} + [B]{u] = {x} + {u}
-inv[M] [K] -inv[M] [C] inv[M] [C]

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by