%% State-Space Representation of Mass-Spring System
% Generate the state-space representation of a damped mass-spring system that obeys the differential equation
% \ddot{w}+0.01\dot{w}+w=u(t).
% The measurable quantity is the acceleration, y=\ddot{w}, and u(t) is the driving force. In Laplace space, the system is represented by
% Y(s)={{s^2\;U(s)}\over{s^2+0.01s+1}}.
% The system has unit gain, a double zero at s=0, and two complex-conjugate poles.

z = [0 0];
p = roots([1 0.01 1])
k = 1;

%
% Use zp2ss to find the state-space matrices.

[A,B,C,D] = zp2ss(z,p,k)

% Copyright 2012 The MathWorks, Inc.