How to perform non linear least square regression of eigenvalues of a matrix (matrix elements being some function of independent variable and parameters to be optimized)?
1 view (last 30 days)
Show older comments
Hi, I am a beginner in MATLAB and struggling with this one code. I have a (4x4) matrix whose elements are function of independent variable and parameters (say a,b,c are parameters) and x is independent variable. e.g. M= [a+b*exp(x*b),c*b*exp(x*c)....;c+a*exp(x*b)....] the eigenvalues of this matrix are y(dependent variables) I want to fit my data to.
I have the data set Xexp=[x1,x2,x3......] and Yexp=[y1,y2....]
I am trying to fit the data set (X,Y) to the eigenvalue "y" (say 2nd eigenvalue) of the matrix (M) using "lsqnonlin" where at the end of the function program I calculate "Y-y" so as to be minimized by the lsqnonlin e.g.
phiLSQ= lsqnonlin(@(phi) lambdafn(phi), initial_param); %command to start regression in main program
function LErr = lambdafn(phi) %start of the function
I am providing the data set (X,Y) in function program itself.
when I run the script I get following error
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in lambdafn (line 31)
Q=[a+b*exp(x*b),c*b*exp(x*c)....;c+a*exp(x*b)....] ; %the complete matrix
Error in @(phi)lambdafn(phi)
Error in lsqnonlin (line 194)
initVals.F = feval(funfcn{3},xCurrent,varargin{:});
Error in lambda (line 32)
phiLSQ= lsqnonlin(@(phi) lambdafn(phi), initial_param);
Caused by:
Failure in initial user-supplied objective function evaluation. LSQNONLIN cannot continue.
Thanks
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!