### 1.30 Determine the response of a system to step input with nonzero initial conditions

Problem: Given a system represented by state space, how to determine the response with nonzero initial conditions in the states and when the input is a step input?

Mathematica

 Remove["Global*"]; a = {{-0.5572, -0.7814}, {0.7814, 0}}; c = {{1.9691, 6.4493}}; sys=StateSpaceModel[ {a,{{1},{0}},c,{{0}}}]  x0 = {1,0}; y = OutputResponse[{sys,x0}, UnitStep[t],{t,0,20}]; Plot[y,{t,0,20}, PlotRange->{{0,20},{0,13}}, GridLines->Automatic, GridLinesStyle->Dashed, Frame->True, ImageSize->300, AspectRatio->1, FrameLabel->{{"y(t)",None}, {"t", "system response to initial\ conditions and step input"}}, RotateLabel->False, PlotStyle->Red] 

Matlab

 A = [-0.5572 -0.7814;0.7814 0]; B = [1;0]; C = [1.9691 6.4493]; x0 = [1 ; 0]; sys = ss(A,B,C,[]); [y1,t] = initial(sys,x0,20); y2 = step(sys,t); plot(t,y1+y2,'r'); title(['initial conditions and step'... 'input response']); xlabel('t *sec)'); ylabel('y(t)'); grid set(gcf,'Position',[10,10,320,320]); `