error using matlabFunction : 'Error: argument must be of type 'Type:arithmetical' [cos]

22 views (last 30 days)
I am attempting to write a symbolic matrix to a function using 'matlabFunction':
Here is my code, M_c is a 9x9 symbolic matrix: f = matlabFunction(M_c,'file','cluster_mass_eval')
This is the error I get:
??? Error using ==> mupadengine.mupadengine>mupadengine.feval at 162 Error: argument must be of type 'Type::Arithmetical' [cos]
Error in ==> sym.matlabFunction>optimize at 392 list = feval(symengine,'mlOptimizeWithIntermediates',f);
Error in ==> sym.matlabFunction>writeMATLAB at 367 [f,temps] = optimize(f);
Error in ==> sym.matlabFunction at 117 g = writeMATLAB(funs,file,varnames,outputs,body);
Is this saying that I can't have trigonometric functions of symbolic variables?
I am searching for the best way to be able to evaluate this symbolic matrix in a loop so if 'matlabFunction' isn't the best thing to use i welcome other suggestions.
Thanks, kyle
Kyle Stanhouse
Kyle Stanhouse on 10 Aug 2011
that fix worked....any observations on the other error?
if i use eval on my symbolic matrix i get this error:
??? Error using ==> evalin
Undefined function or method 'arg' for input arguments of
type 'double'.
Error in ==> sym.eval at 14
s = evalin('caller',vectorize(map2mat(char(x))));
Is it possible that my symbolic matrix is in a form that none of these evaluation functions will take?
I have gotten the matrix to evaluate previously by manually writing it to a file and tediously 'finding and replacing' notation that matlab won't evaluate (even though matlab symbolic manipulations output the expressions with said un-evaluate-able notation)....but i figured there has got to be a better way...

Sign in to comment.

Accepted Answer

Kai Gehrs
Kai Gehrs on 11 Aug 2011
just an additional comment: the names theta and beta are reserved names in MuPAD (which is the symbolic engine for the Symbolic Math Toolbox). They are the names of special functions - same as psi, gamma etc.
Depending on the version of MATLAB you are using, it may be necessary to avoid these names, since they cause name conflicts. This behavior is fixed in the more current MATLAB versions.
Best regards,
-- Kai

More Answers (1)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!