char produces ln instead of log

1 visualización (últimos 30 días)
Sergei
Sergei el 26 de Mzo. de 2012
Editada: Walter Roberson el 30 de Oct. de 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 comentarios
Kevin Holst
Kevin Holst el 26 de Mzo. de 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 el 26 de Mzo. de 2012
Editada: Walter Roberson el 30 de Oct. de 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).

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 26 de Mzo. de 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.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by