% otdr ideal
y=[11.487 9.356 7.62 6.206 5.055 4.117 3.353 2.73 2.225 1.812];
zi=(1/2)*(10*log10(y));
x=linspace(0,9,10);
ai=polyfit(x,zi,1);ateni=-ai(1)/2
%figure(1),plot(x,zi),xlabel('1 div=2km'),grid,title('ideal');

% otdr real fara zgomot termic
y=[11.483 9.3585 7.61749 6.203 5.0525 4.1145 3.25036 2.729727 2.22623 1.8111];
zr=(1/2)*(10*log10(y));
ar=polyfit(x,zr,1);atenr=-ar(1)/2
%figure(2),plot(x,zr),xlabel('1 div=2km'),grid,title('real fara');

% otdr real cu zgomot termic
y=[11.47295 9.3393 7.6064 6.190319 5.05158 4.14 3.33896 2.7221 2.203 1.8006];
zrz=(1/2)*(10*log10(y));
arz=polyfit(x,zrz,1);atenrz=-arz(1)/2
%figure(3),plot(x,zrz),xlabel('1 div=2km'),grid,title('real cu');

c=arz(1)*x+arz(2);figure(4),hold on,plot(x,c,'y'),plot(x,zrz,'r'),grid,hold off 