Help with displayFormula from symbolic math toolbox
14 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Christopher Creutzig
2020-3-9
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!