%
% SECOND ORDER ADATIVE CONTROLLER
%
% Reference Model Gr(s) = 1/(s^2+as+1)
    a = 2;
% Unknown Plant Gp(s) = K/(s^2+bs+1)
    K = 1;
    b = 1.9;
% Adaptive Controller H(s) = int[dKp = myu*Error], Kp(0) = Kp0
    Kp0 = 0;
    myu = 1;
% Simulation
    sim('second_order.slx');
% Results
    subplot(311), plot(time, Yr, time, Yp), grid on, xlabel('time [sec]'), ylabel('output')
    subplot(312), plot(time, error), grid on, xlabel('time [sec]'), ylabel('error')
    subplot(313), plot(time, Kp), grid on, xlabel('time [sec]'), ylabel('Kp')
% Final Results
    N = length(error);
    Final_ERROR = error(N)
    Final_Kp = Kp(N)
    


    