??? Error using ==> evalin Undefined function or method 'arctan' for input arguments of type 'double'.
8 views (last 30 days)
Show older comments
I'm trying to figure out why I keep getting the error:
??? Error using ==> evalin Undefined function or method 'arctan' for input arguments of type 'double'.
I'm trying to optimize a large function with symbolic variables in it using Hessian and gradient matrices and multidimensional Newton optimization techniques (namely, x1=x0-(H(x0))^-1)*grad(f(x0))).
That error crops up at different points in running. Sometimes it happens after the first iteration; other times, it happens after 3 or 4 runs through.
The objective function is: (T-atan(((Py+Vy*k)-Psy)/((Px+Vx*k)-Psx)); where Px, Vx, Py, and Vy are the symbolic variables that are in need of optimization. The others have values being assigned to them already. The command jacobian is used to find the gradient, and then applied again to acquire the Hessian. The Hessian and Jacobian are summed 30 times with varying numbers to form a large expression. An appropriate initial guess is being used. The eval command is being used to compute the gradient and Hessian matrices with values subbed in.
Any ideas on why this error keeps occurring?
2 Comments
Sean de Wolski
on 2 Dec 2011
What is the string you're feeding evalin? This is why the use of evalin/eval/assignin bis recommended against because bugs are hard to catch.
Are you sure you don't have 'arctan' instead of 'atan' somewhere?
Accepted Answer
Walter Roberson
on 2 Dec 2011
You should not use evalin() to do substitutions in symbolic expressions. Use subs() instead, or use matlabFunction to convert to a non-symbolic function handle that can then be executed with numeric arguments.
The symbolic arc tangent in MuPAD is arctan() and that is what is going to be in the character vector, as displaying a symbolic expression displays the MuPAD expression without converting it to any MATLAB routine names. It was never intended that eval'ing a MuPAD expression at the MATLAB level would necessarily be meaningful.
3 Comments
More Answers (0)
See Also
Categories
Find more on Special Values 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!