Representing Symbolic Variables as Equations in Live Scripts

조회 수: 14 (최근 30일)
Guillermo Rubio Gomez
Guillermo Rubio Gomez 2019년 10월 4일
답변: Steven Lord 2019년 10월 4일
I would like to represent the content of symbolic variables as equations in a Live Script.
So far i'm trying with texlabel function:
texlabel(dtheta)
ans = '({L_{2}} ({L_{2}}^{2} - {L_{1}}^{2} - {2} {W} {w} + {W}^{2} + {w}^{2}))/({2} {L_{1}}^{2} ({W} - {w})^{3} ({1} - ({L_{1}}^{2} - {L_{2}}^{2} + ({W} - {w})^{2})^{2}/({4} {L_{1}}^{2} ({W} - {w})^{2}))^{{3}/{2}})'
Then I copy the output Tex expression into an equation, pasting as LaTex expression:
However, it doesn't recognize the fraccions.
I can see that, by clicking the variable in the LiveScript, the expression appears perfectly.
Is there any better way to do it?
Thank you very much.

채택된 답변

Steven Lord
Steven Lord 2019년 10월 4일
Hmm. It looks like texlabel doesn't do any special processing for fractions. That kind of makes sense; ideally you wouldn't want the labels for your axes to be so tall that they protrude into the visible space of the axes or extend beyond the limit of the figure window.
Since you're working with symbolic expressions, I'd probably just use the latex function. I'll make a symbolic expression:
>> syms a b c x
>> S = solve(a*x^2+b*x+c == 0, x)
S =
-(b + (b^2 - 4*a*c)^(1/2))/(2*a)
-(b - (b^2 - 4*a*c)^(1/2))/(2*a)
Let's convert that to LaTeX and copy it to the clipboard.
>> clipboard('copy', latex(S));
Now open a Live Editor window and in the Insert tab of the Toolstrip click the triangle under the Equation icon. Select LaTeX Equation and paste into the box where you're asked to enter your LaTeX equation code.
Or since you're working in the Live Editor anyway, just run the first two lines of my example in the Live Editor. The output will be formatted in "pretty print" form.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by