function [ fval ] = LSQfunc(params,x,y)
% this function can be called by fminsearch
% the first input 'params' is a vector that contains the parameters
% that are varied by fminsearch in order to minimize 'fval'
A=params(1);
B=params(2);
model=A*x+B;
fval=sum( (y-model).^2 );
end