Skip to content
Permalink
bf055a4ea9
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
13 lines (9 sloc) 219 Bytes
function [a,fx,r2]=least_squares(Z,y)
a = (Z'*Z)\(Z'*y);
%Define function
fx=Z*a;
%Sum equation
Sr = sum((y-Z*a).^2);
%equation for coefficient of determination
r2 = 1-Sr/sum((y-mean(y)).^2);
end