char produces ln instead of log

2 views (last 30 days)
Sergei
Sergei on 26 Mar 2012
Edited: Walter Roberson on 30 Oct 2023
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!
  2 Comments
Kevin Holst
Kevin Holst on 26 Mar 2012
Have you tried eval('char([102 108 105 112 108 114 40 39 116 105 120 101 39 41])')?
Why are you needing to use eval in this code? Could you post some of your code?
Sergei
Sergei on 26 Mar 2012
Edited: Walter Roberson on 30 Oct 2023
I am using a code written by someone else. You can find it here:
You can, for example, run "Example 1" (by running neoclassical_model_run.m).
The eval part appears in num_eval.m file.
Typically, I found this program to work well. However, I have recently tried to use it to solve a model where it gave me this trouble (but also not always, only for some parameter combinations).

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 26 Mar 2012
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.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!