linear least sqaures minimization coding needed urgently
linear least sqaures minimization coding needed urgently
(OP)
Hi all!
I need to find the parameters a, b and c by solving the following linear least-squares parameter minimisation problem:
sum[i=1,1=n{a*X_i + b*Y_i + c - Z_i}^2]
where vectors X, Y and Z are known.
Any idea on how to implement in Matlab. Please I really need help cos it is a small part of my ptoject but it has got me stuck
thanks
I need to find the parameters a, b and c by solving the following linear least-squares parameter minimisation problem:
sum[i=1,1=n{a*X_i + b*Y_i + c - Z_i}^2]
where vectors X, Y and Z are known.
Any idea on how to implement in Matlab. Please I really need help cos it is a small part of my ptoject but it has got me stuck
thanks





RE: linear least sqaures minimization coding needed urgently
Try this
CODE
% rewrite the equation as a*X + b*Y + c*1 = Z
% now write in matrix form Ax = f
[rows, dummy] = size(X); %number of elements in the vector
A = [X Y ones(rows,1)];
f = Z;
x = A\f; % do the least squares
a = x(1)
b = x(2)
c = x(3)
--
Dr Michael F Platten