Help with displayFormula from symbolic math toolbox

14 visualizaciones (últimos 30 días)
andrea
andrea el 8 de Mzo. de 2020
Respondida: Christopher Creutzig el 9 de Mzo. de 2020
Hello everyone, i've got a simple question but i can't find the answer in the forum:
The function displayFormula from the symbolic math toolbox is working only in live editor , I mean it gives output only if used in a .mlx script.Is this the way it's supposed to work or there is a way to use this function even in the command window ?
Thanks in andvace.

Respuestas (1)

Christopher Creutzig
Christopher Creutzig el 9 de Mzo. de 2020
Rendered formulas are only available in Live Editor, whether you use displayFormula or just have standard output.
In Command Window, formulas are shown as plain old text, but the substitutions of displayFormula still do take place. E.g., here are the second and third example from the documentation:
>> S = "m*diff(y,t,t) == m*g-k*y";
>> symstr = ["'The equation of motion is'"; S;"'where k is the elastic coefficient.'"];
>> displayFormula(symstr)
The equation of motion is
m*diff(y, t, t) == m*g - k*y
where k is the elastic coefficient.
>> S = "exp(2*pi*i)";
>> symstr = "1 + S + S^2 + cos(S)";
>> displayFormula(symstr)
1 + exp(2*pi*1i) + exp(2*pi*1i)^2 + cos(exp(2*pi*1i))
Note that this last output would automatically simplify if used as a sym:
>> 1 + exp(2*sym(pi)*1i) + exp(2*sym(pi)*1i)^2 + cos(exp(2*sym(pi)*1i))
ans =
cos(1) + 3

Categorías

Más información sobre Formula Manipulation and Simplification en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by