x=[0.2, 0.4, 0.6, 0.8, 1];
I=[11912, 10171, 8729, 7549, 5868];
I2=[7403, 6327, 5569, 4921, 4070];
I3=[15172, 13411, 12278, 11489, 10322];

y=zeros(1,length(I));
y2=zeros(1,length(I2));
y3=zeros(1,length(I3));

i=1;
for i=1:length(I)
y(i)=log10(16924/(I(i)));
y2(i)=log10(9623/(I2(i)));
y3(i)=log10(18167/(I3(i)));
i=i+1;
end

p = polyfit(x,y3,1);
yfit = polyval(p,x);
yresid = y3 - yfit;
SSresid = sum(yresid.^2);
SStotal = (length(y3)-1) * var(y3);
rsq = 1 - SSresid/SStotal;


figure(1)
hold on
plot (x,y,'r*')
plot (x,y2,'b*')
plot (x,y3,'g*')
legend('Červená složka spektra','Modrá složka spektra','Zelená složka spektra','Location','southeast')
legend ('boxoff')
xlabel('Poměr základního roztoku a destilované vody (koncentrace)[-]')
ylabel('Absorbance[-]')
lsline
hold off
