# Solve ODE in State-space form

Is it possible to solve an ODE in state-space form in mathematica? Such as

 x'[t]=A.x[t]


I attempted

w = 2;
T = 2 Pi/w;
a = 0.4; b = 4.0; d = 0.3;

A = T {{0, 1}, {-a - b Cos[2 t], -d}}

x[t_] := {x1[t], x2[t]}
sol = NDSolve[{x'[t] == A.x[t], x == x' == 0}, x, {t, 0, 1}]


NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions.

• I do not know why the numerical gives these warnings, but your solutions are zero according to DSolve: w = 2; T = 2 Pi/w; a = 0.4; b = 4.0; d = 0.3; x[t_] := {x1[t], x2[t]} A0 = T {{0, 1}, {-a - b Cos[2 t], -d}}; sol = DSolve[{x'[t] == A0.x[t], x == x' == 0}, x[t], t] which gives {{x1[t] -> 0, x2[t] -> 0}} on V 10.1 – Nasser Apr 6 '15 at 16:37

I ve modified slightly your problem to one which works:

I used exact numbers

w = 2;
T = 2 Pi/w;
a = 4/10; b = 4; d = 3/10;

A = T {{0, 1}, {-a - b Cos[2 t], -d}}


I then drop the Initial condition on derivatives which are redundant given the order of your equation:

sol = NDSolve[{x'[t] == A.x[t], x == {1, 2}},x[t] , {t, 0, 1}]


then I plot the result

 ParametricPlot[x[t] /. sol, {t, 0, 1}] ## Update

If you insist on {0,0} as initial conditions you get (as @nasser points out)

 sol = DSolve[{x'[t] == A.x[t], x == {0, 0}}, x[t], {t, 0, 1}]


(* {{x1(t)->0,x2(t)->0}} *)

## Update 2

Just for fun mathematica can write the general solution for arbitrary ICs

T=a=b=d=.;
A = T {{0, 1}, {-a - b Cos[2 t], -d}}
x[t_] := {x1[t], x2[t]}
sol = DSolve[{x'[t] == A.x[t],
x == {a1,a2}}, x[t], t] //
FullSimplify • That's perfect, thanks! No need for {0,0}, I just chose at random. – gKirkland Apr 6 '15 at 16:43
• you are welcome… – chris Apr 6 '15 at 16:44

If you wanted to use StateSpaceModel to implement the solution, you could do the following

ssm = StateSpaceModel[
{x1'[t] == Pi x2[t],
x2'[t] == Pi (-a - b Cos[2 t]) x1[t] - d Pi x2[t]},
{{x1[t], 0}, {x2[t], 0}, {x1'[t], 0}, {x2'[t], 0}},
{{u[t], 0}},
{x1[t], x2[t]},
t
] Then find the StateResponse

response = StateResponse[{ssm, {1, 2}}, {UnitStep[t]}, {t, 0, 1}]


Out: {InterpolatingFunction[][t], InterpolatingFunction[][t]}

And then ParametricPlot it

ParametricPlot[response, {t, 0, 1}] 