This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/regression/code/lsqError.m

14 lines
460 B
Matlab

function error = lsqError(x, y, parameter)
% Objective function for fitting a linear equation to data.
%
% Arguments: x, the input values
% y, the corresponding measured output values
% parameter, vector containing slope and intercept
% as the 1st and 2nd element
%
% Returns: the estimation error in terms of the mean sqaure error
y_est = x .* parameter(1) + parameter(2);
error = meanSquareError(y, y_est);
end