How can I convert a mupad to a MATLAB function when using tex symbols?

I am using mupad for some symbolic calculations. Since I want to export to latex, I use tex-like symbols as variable names, e.g.
`A_{segment}`(`ξ`) := r*int(`ξ`*`P_{LD}`,`ξ`=0..`ξ_{max}`)
Now I want to convert these to MATLAB functions for numeric evaluation. First problem is with getVar, what is the variable name I should use? Second problem, assuming I convert the above to
A_S := r*int(`ξ`*`P_{LD}`,`ξ`=0..`ξ_{max}`)
so I can use
A_segment = getVar(mphandle,'A_S')
I get something like
A_segment = (`P_{LD}`*r*(r - x)^2)/2
That leads to the second problem, this symbolic term can't be converted to a MATLAB function:
>> matlabFunction(A_segment)
Error using sym/matlabFunction>checkVars (line 159)
Variable names must be valid MATLAB variable names.
Error in sym/matlabFunction (line 104)
vars = checkVars(funvars,opts);

Answers (0)

Asked:

on 6 Nov 2014

Community Treasure Hunt

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

Start Hunting!