

k=load('pol1.txt');
x = k(:,1);
y = k(:,2);


a = [500 600 1 10 80];

options = optimset('MaxFunEvals', 2000000);
[b fval] = fminsearch(@(a) sum((myfun(x,a)-y).^2), [a], options);
figure;plot(x,y,'bo',x,myfun(x,b),'LineWidth',2);
title('Cavendishuv experiment');
xlabel('t [s]')
ylabel('\Delta x [cm]')

legend('data', 'regrese nejmensi ctverce')
b

fval
