% otdr ideal
y=[273.0749 227.1339 188.9217 157.1382 130.7018 108.5216];
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=[273.0112 227.0955 188.8919 157.1371 130.6725 108.7236];
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=[272.9983 227.0712 188.8706 157.1162 130.6713 108.7022];
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 