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