d1 = [3.45 3.73 3.45 3.45 3.73];

d2 = [4.689 4.790 4.969 4.841 5.384];

d3 = [9.952 10.117 10.418 10.350 10.018];



data = [49.78 mean(d1) sqrt(var(d1));

        59.30 mean(d2) sqrt(var(d2));

        110.76 mean(d3) sqrt(var(d3))];

    

errorbar(data(:,1),data(:,2),data(:,3),'o','markersize',10);

grid on;

xlabel('Distance traveled by signal');

ylabel('Attenuation in dBm = 20log(V_R/V_I)');

title('Attenuation of pulse amplitude as function of distance');

ylim([0 11]);

xlim([0 120]);



[a,aerr,chisq,yfit] = fitlin(data(:,1),data(:,2),data(:,3))

x = linspace(0,120); hold on;

plot(x,a(1)+a(2)*x,'r','LineWidth',2);