close all
clear all

m4o=load('degrauM4nocontrol_volt_posEff_kt0.txt');
m4c=load('degrauM4_volt_posEff_controlReq.txt');
step=ones(length(m4o),1)*0;

N=71;
figure;
plot(m4o(1:N,1),m4o(1:N,3),'m',m4c(1:N,1),m4c(1:N,3),'r',m4o(1:N,1),step(1:N),'b')
grid on
xlabel('time (s)');
ylabel('Position (degrees)')
legend('Step requested','Response without control','Response with control','location','SouthEast');

erroro=m4o(:,1)-m4o(:,3);
errorc=m4c(:,1)-m4c(:,3);
figure;
plot(m4o(1:N,1),erroro(1:N,1),'r',m4c(1:N,1),errorc(1:N,1),'b')
grid on
xlabel('time (s)');
ylabel('Position (degrees)')
legend('Open loop response error','Closed loop response error','location','NorthEast');

% N=100;
% figure;
% m42a=load('degrau_control_m2+4_KP007_este.txt');
% m42b=load('degrauM24_volt_posEff_controlReq.txt');
% plot(m42a(1:N,1),m42a(1:N,2),'b',m42b(1:N,1),m42b(1:N,3),'r')
% grid on
% xlabel('time (s)');
% ylabel('Position (degrees)')
% legend('Traject -90º=>0º','Traject -45º=>+45º','location','SouthEast');
% 
% figure;
% m42a=load('degrauM24nocontrol_volt_posEff_kt0.txt');
% m42b=load('degrauM24_volt_posEff_controlReq.txt');
% plot(m42a(1:N,1),m42a(1:N,3),'r',m42b(1:N,1),m42b(1:N,3),'b')
% grid on
% xlabel('time (s)');
% ylabel('Position (degrees)')
% legend('Open loop response','Closed loop response','location','SouthEast');
