12 lines
413 B
Matlab
12 lines
413 B
Matlab
function error = lsq_error(parameter, x, y)
|
|
% Objective function for fitting a linear equation to data.
|
|
%
|
|
% Arguments: parameter, vector containing slope and intercept (1st and 2nd element)
|
|
% x, the input values
|
|
% y, the measured system output
|
|
%
|
|
% Retruns: the estimation error in terms of the mean sqaure error
|
|
|
|
y_est = x .* parameter(1) + parameter(2);
|
|
error = meanSquareError(y, y_est);
|