%Define dynamics
A = [0.2 0; 0.5 -0.2];    % open-loop A-matrix has poles in 0.2 and -0.2
B = [-0.2; 0];
C = [1 0; -0.96 0.784];
D = 0;
G=ss(A,B,C,D);

%Kill one measurement
C2=C(2,:);
Gred=ss(A,B,C2,D);

%Create LQR controller
Q=zeros(2); R=1;    %Minimum input usage
Klqr=lqr(A,B,Q,R);

%Set disturbance signal parameters (for use in Simulink)
loadD=1; stateD=1; LTime=10; STime=40;

%Create Kalman filter based on (A,B,C2):
[Kest1,L1,P1]=kalman(Gred,1,0.1);

%Simulate each case for tf=80.
%Simulation variables are stored in workspace, with naming convention
%   VariableName_CASE_#
%To avoid opening simulink for each case, use the syntax 
%   sim('caseA',80)
