M1=249;
M2=454;
M3=713;
M4=666;
MB=1946;

% Lista de massas utilizada
mass   = [0;
          M1;
          M2;
          M1+M2;
          M4;
          M4+M1;
          M4+M2;
          M4+M2+M1;
          M4+M3;
          M4+M3+M1;
          M4+M3+M2;
          M4+M3+M2+M1;
          MB;
          MB+M1;
          MB+M2;
          MB+M2+M1];

% Saída dos sensores de Força
% -------------
% |blue  green|
% |           |
% |           |
% |           |
% |           |
% |           |
% |white brown|
% -------------
%
colors = ['Sensor Azul    ';
          'Sensor Verde   ';
          'Sensor Branco  ';
          'Sensor Castanho'];

%         blue green white brown
output = [  40    40    40    40;
            54    51    55    53;
            67    66    69    66;
            84    83    84    81;
            82    81    81    79;
            98    97    96    94;
           110   110   108   106;
           127   123   124   120;
           128   125   124   122;
           144   137   142   135;
           158   147   155   147;
           173   160   177   162;
           160   157   171   163;
           174   166   190   186;
           186   180   200   197;
           208   193   214   210];

lin_param=[];
close all
for i=1:size(output,2)
    b = robustfit(mass(1:12),output(1:12,i));
    corr_coef=corr2(mass(1:12),output(1:12,1));
    b=[b;corr_coef];
    lin_param = [lin_param b];
    lin = b(1)+mass*b(2);
    
    figure;
    plot(mass,output(:,i),'.',mass,lin);
    xlabel('Massa (g)')
    ylabel(colors(i,:));
end

% Lista de massas utilizada
mass   = [0;
          M2;
          M4;
          M4+M2;
          M4+M3;
          M4+M3+M2;
          MB;
          MB+M2;
          MB+M4;
          MB+M4+M2;
          MB+M4+M3;
          MB+M4+M3+M2;
          MB+M4+M3+M2+M1];

%         blue green white brown
output = [  40    40    41    40;
            48    40    42    48;
            55    46    46    56;
            64    55    54    64;
            69    60    59    69;
            77    69    67    75;
            85    65    64    86;
            95    71    71    95;
           100    75    75   102;
           110    82    83   111;
           114    85    87   116;
           125    91    92   124;
           130    94    97   129];

col=['b','g','c','k'];
           
figure;
axes('fontsize',14)
hold on
for i=1:size(output,2)
    plot(mass,output(:,i),col(i),'linewidth',2);
end
hold off
xlabel('Massa (g)')
legend(colors)
grid on