% M-file that computes controller gains, state-space model, and

% digital filters.

Parameters; % runs the parameter script

% Computes the A matrix for the state space equation.

A(1,:) = [0 0 1 0 0];

A(2,:) = [0 0 0 1 0];

A(3,1) = 0;

A(3,2) = Kstiff/(Jbase*L);

A(3,3) = -(Km*Kg)^2/(R*Jbase);

A(3,4) = 0;

A(3,5) = 0;

A(4,1) = 0;

A(4,2) = -Kstiff*(Jload+Jbase)/(L*Jbase*Jload);

A(4,3) = (Km*Kg)^2/(R*Jbase);

A(4,4) = 0;

A(4,5) = 0;

A(5,:) = [1 0 0 0 0];

% Computes the B matrix for the state space equation.

B(1) = 0;

B(2) = 0;

B(3) = (Km*Kg)/(R*Jbase);

B(4) = -(Km*Kg)/(R*Jbase);

B(5) = 0;

B = B';

% Computes the C and D matrix for the state space equation.

C = [1 0 0 0 0; 0 1 0 0 0];

D = [0 0]';