% otdr ideal
y=[2193.075 2169.047 2147.134 2127.148 2108.922 2092.299];
zi=(1/2)*(10*log10(y));
x=linspace(0,5,6);
ai=polyfit(x,zi,1);ateni=-ai(1)
%figure(1),plot(x,zi),xlabel('1 div=1km'),grid,title('ideal');

% otdr real fara zgomot termic
y=[2173.155 2158.166 2137.079 2131.573 2109.628 2077.968];
zr=(1/2)*(10*log10(y));
ar=polyfit(x,zr,1);atenr=-ar(1)
%figure(2),plot(x,zr),xlabel('1 div=1km'),grid,title('real fara');

% otdr real cu zgomot termic
y=[2171.69 2156.459 2139.199 2131.075 2108.892 2077.5];
zrz=(1/2)*(10*log10(y));
arz=polyfit(x,zrz,1);atenrz=-arz(1)
%figure(3),plot(x,zrz),xlabel('1 div=1km'),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 