Problem with subfunction within lsqnonlin??

2 views (last 30 days)
Becket Hui
Becket Hui on 9 Sep 2012
Commented: Pranav Pathak on 27 Jul 2018
I got the following error which involves matlab not knowing how to multiply a scalar with a sparse structure (which is just another number). Does anyone know what is going on?
Error using * MTIMES is not supported for one sparse input and one single input.
Error in trdog (line 30) grad = D*g;
Error in snls (line 315) [sx,snod,qp,posdef,pcgit,Z] = trdog(x,g,A,D,delta,dv,...
Error in lsqncommon (line 175) [xC,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT,msgData]=...
Error in lsqnonlin (line 237) [xCurrent,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
Error in DCE_Analysis (line 35) [Pfinal, chi2] = lsqnonlin(@(P)lSqErr(insignal,inserr,tarr,AIFp,R1T,P),Pstart,Plb,Pub,options);
  1 Comment
Becket Hui
Becket Hui on 10 Sep 2012
I think I figured it out, it appears that everything must be type double (can't be single) or else it will fail.

Sign in to comment.

Answers (1)

Steve Grikschat
Steve Grikschat on 25 Sep 2012
All values returned to lsqnonlin must be of data type double.
  1 Comment
Pranav Pathak
Pranav Pathak on 27 Jul 2018
Hello Sir,
Do we have any work around for this case?
I need to pass a single datatype value to the lsqnonlin function.
With Typecasting, I am able to resolve the error but this procedure does NOT optimize the value. It stops after one iteration.
Please let me know your feedback.

Sign in to comment.

Categories

Find more on Sparse Matrices 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!