I'm attempting to use fminsearch to optimise the components of a matrix to fit some data.
The equation I am looking to fit to the data is:
(y - A*x)^2
where y and x are 150x3 matrices of data, and A is a 3x3 matrix where A(i,j) are the parameters I'm looking to optimise.
The code I have so far is:
type sseval
function sse = sseval(p,x,y)
A1 = p(1);
A2 = p(2);
A3 = p(3);
A4 = p(4);
A5 = p(5);
A6 = p(6);
A7 = p(7);
A8 = p(8);
A9 = p(9);
M = [A1 A2 A3; A4 A5 A6; A7 A8 A9];
sse = sum((y - M*x)^2);
end
And then seperately:
fun = @(p)sseval(p,x,y)
p0 = rand(9,1)
bestp = fminsearch(fun,p0)
When i try this the error i recieve is:
Error using @(p)sseval(p,x,y)
'sseval' is used in Curve Fitting via Optimization.
Error in fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});
0 Comments
Sign in to comment.