6 lines
172 B
Matlab
6 lines
172 B
Matlab
function error = lsq_error(parameter, x, y)
|
|
% parameter(1) is the slope
|
|
% parameter(2) is the intercept
|
|
|
|
f_x = x .* parameter(1) + parameter(2);
|
|
error = mean((f_x - y).^2); |