%bike_sfb.m
%Design of State feedback for Whipple bicycle
%   kja 070820
%   Get process model
bike_linmod;     
%   Desired closed loop eigenvalues
P=[1*[-1+i -1-i] -2 -10];
K=acker(A,B,P);Acl=A-B*K;
C=[0 1 0 0];
Kr=-1/(C*inv(Acl)*B);
disp('Feedback gain K=');disp(K)
disp('Refererence gain Kr=');disp(Kr)
%   Check the results
n=size(A);disp('Specified closed loop eigenvalues')
disp(P);
disp('Closed loop eigenvalues obtained')
disp(eig(Acl)');
%   Collect matrices of closed loop system
bike_cls=ss(Acl,B*Kr,C,0);