% Analysis of data on shadow sensor resolution versus PD open light current
% from T0900496-v4

load 'BOSEM_PD_Res.mat'; % .mat version of original text file
[p S] = polyfit(data(:,2),data(:,3),1);
resid = data(:,3) - p(1)*data(:,2)-p(2);
s=std(resid);
m=mean(data(:,3));
fitx=linspace(min(data(:,2)),max(data(:,2)))
fity = p(1)*fitx+p(2);

figure(1)
hold off
scatter(data(:,2),data(:,3))
hold on
plot(fitx,fity,'r-');
xlabel('Open light PD current (uA)')
ylabel('Resolution (V/m)')
title('Scatter plot of data for 78 BOSEMs from T0900496-v4')

percentscatter = 100*s/m
