MATLAB: Char produces ln instead of log

charlnlog

I have a system of symbolic equations f, one of which contains log(x). When I try to evaluate it with eval(f), it calls at some point char(x), which replaces "log" with "ln", and matlab cannot process it. Did anybody experience a similar problem? Is there a workaround? Thanks!

Best Answer

Don't eval() a symbolic equation. There are too many subtle syntax and function differences.
If you have all of the values needed for the symbolic equation, you can subs() the values into the equation.
If you will be evaluating the same symbolic equation repeatedly with numeric values substituted for all of the variables, use matlabFunction() to transform the symbolic function to an anonymous function.
Related Question