Representing Symbolic Variables as Equations in Live Scripts
14 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!