data = load('imaging.txt');

Oinv = 1./data(:,1);

Iinv = 1./data(:,2);

plot(Oinv,Iinv,'o','markersize',10);

grid on;

xlabel('Inverse object distance in cm^-^1, 1/O');

ylabel('Inverse imaging distance in cm^-^1, 1/I');



function_linear = @(a,x) a(1)-a(2)*x;

a0 = [0.05 -1];

a = lsqcurvefit(function_linear,a0,Oinv,Iinv);

x = linspace(0.025,0.06);

y = function_linear(a,x);

hold on;

plot(x,y);

title('Fitted line: y = 0.0683 - 1.0651*x');