Least-squares fit of data to y = c(1)*x + c(2)
% linefit.m
% @shortDesc: Least-squares fitting
% @fullDesc: Least-squares fit of data to y = c(1)*x + c(2)
function c = linefit(x,y)
x=x(:);
y=y(:);
A=[x ones(size(x))];
c=(A'*A)\(A'*y);
end
Attachments:
You must be
logged in to view attached files.