Second order to first order system

Hi, How this second order system can be converted to a first order system:?
not really sure how to get this solution?
any help will be appreciated. Thanks

3 Comments

@Cesar, this is intersting but is not a Matlab question. And it smells a lot like homework...
Check the left hand side of the first equation. I suspect there is a + sign missing that should be in there.
There is an error in the first equation.
It should be:
The Symbolic Math Toolbox can get part way there using odeToVectorField, however it would require effort to get the ‘A’ matrix from the vector field (first output) result. The other vectors you would simply have to create.
@Star Strider thanks for your reply. Maybe I was not clear enough. This is what I have:
omega = 2;
zeta = sqrt(3)/4;
sympref('AbbreviateOutput', false);
syms x(t) y(t) u
eqn = diff(x, 2) + 2*zeta*omega*diff(x) + (omega^2)*x == (omega^2)*u;
[V, S] = odeToVectorField(eqn)
A = [0 1; -4 -sqrt(3)];
B = [0; 4];
C = [1 0];
D = 0;
sys = ss(A, B, C, D)
However this solution is different to the one in this comment. I would like to get this solution. not sure how to do it...Any help will be appreciated. Thanks

Sign in to comment.

Answers (1)

One approach (that involves doing an interim Laplace transform on the differential equation) —
omega = 2;
zeta = sqrt(3)/4;
sympref('AbbreviateOutput', false);
syms s t u(t) U X x(t) y(t)
eqn = diff(x, 2) + 2*zeta*omega*diff(x) + (omega^2)*x
eqn(t) = 
inp = (omega^2)*u
inp(t) = 
[V, S] = odeToVectorField(eqn)
V = 
S = 
Leqn = laplace(eqn == inp,t,s)
Leqn = 
Leqn = subs(Leqn, {laplace(x(t),t,s), x(0) subs(diff(x(t),t),0), laplace(u(t),t,s)}, {X, 0, 0, U})
Leqn = 
X = solve(Leqn,X)
X = 
[n,d] = numden(X)
n = 
d = 
np = sym2poly(n/U)
np = 4
dp = sym2poly(d)
dp = 1×3
1.0000 1.7321 4.0000
systf = tf(np, dp)
systf = 4 ----------------- s^2 + 1.732 s + 4 Continuous-time transfer function.
sysss = ss(systf)
sysss = A = x1 x2 x1 -1.732 -2 x2 2 0 B = u1 x1 2 x2 0 C = x1 x2 y1 0 1 D = u1 y1 0 Continuous-time state-space model.
The input is defined as (or ), and the Control System Toolbox normalises the numerator and denomminator. Setting the input to 1 instead of 4 and then substituting appropriately later may give you the essential duplicate of the state space system you described.
I will leave that for you to experiment with. This code does the ‘heavy lifting’ to get your differential equation into a state space realisation. Tweak it to get the result you want.
.

Categories

Asked:

on 1 Oct 2022

Answered:

on 2 Oct 2022

Community Treasure Hunt

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

Start Hunting!