
close all

%help response_ramp

title1= 'Resposta à Rampa: -90º=>+50º, timeStep=200ms, positionStep=5º, Carga=M1+M4=933g';
files1=['rampa-90;+50_M14_kp=0.06kd=0.00#posReq_posEff_contReq.txt',
        'rampa-90;+50_M14_kp=0.06kd=0.04#posReq_posEff_contReq.txt',
        'rampa-90;+50_M14_kp=0.10kd=0.04#posReq_posEff_contReq.txt',
        'rampa-90;+50_M14_kp=0.10kd=0.30#posReq_posEff_contReq.txt',
        'rampa-90;+50_M14_kp=0.30kd=0.30#posReq_posEff_contReq.txt',
        'rampa-90;+50_M14_kp=0.30kd=1.50#posReq_posEff_contReq.txt'];
label1=['Kp=0.06     Kd=0.00',
        'Kp=0.06     Kd=0.04',
        'Kp=0.10     Kd=0.04',
        'Kp=0.10     Kd=0.30',
        'Kp=0.30     Kd=0.30',
        'Kp=0.30     Kd=1.50'];

title2= 'Resposta à Rampa: -90º=>+50º, timeStep=100ms, positionStep=?, Carga=M1+M4=933g';
files2=['rampa-90;+50_M14_kp=0.15kd=1.00_dt100_dp5#posReq_posEff_contReq.txt',
        'rampa-90;+50_M14_kp=0.30kd=1.50_dt100_dp2#posReq_posEff_contReq.txt'];
label2=['Kp=0.15, Kd=1.00 (timeStep=100ms, positionStep=5º)',
        'Kp=0.30, Kd=1.50 (timeStep=100ms, positionStep=2º)'];

legenda=['Posição solicitada   ',
         'Percurso COM controlo',
         'Pedido do controlador'];

f2=figure(2);
set(f2,'name',title2);
for i=1:size(files2,1)
    clear array;
    array=load(files2(i,:));
    
    subplot(2,1,i);
    plot(array(:,1),array(:,2),'g',array(:,1),array(:,3),'b',array(:,1),array(:,4),'r');
    
    xlabel(label2(i,:));
    ylabel('Posição (graus)');
    
    if (i==size(files2,1))
        legend(legenda,'location','southeast');
    end
    grid on
end

f1=figure(1);
set(f1,'name',title1);
for i=1:size(files1,1)
    clear array;
    array=load(files1(i,:));
    
    subplot(3,2,i);
    plot(array(:,1),array(:,2),'g',array(:,1),array(:,3),'b',array(:,1),array(:,4),'r');
    
    xlabel(label1(i,:));
    ylabel('Posição (graus)');
    
    if (i==size(files1,1))
        legend(legenda,'location','southeast');
    end
    grid on
end
