Help with displayFormula from symbolic math toolbox

조회 수: 22 (최근 30일)
andrea
andrea 2020년 3월 8일
답변: Christopher Creutzig 2020년 3월 9일
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.

답변 (1개)

Christopher Creutzig
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

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by