Adding latex equation to a Matlab Live Script and Plot the equation

4 ビュー (過去 30 日間)
student_md
student_md 2022 年 1 月 1 日
コメント済み: Walter Roberson 2022 年 1 月 1 日
I have added a latex equation to a Matlab Live Script. (In the Insert tab, by clicking Equation, and selecting LaTeX Equation)
For Example, let's have a latex equation as follows:
\frac{100 (-3)}{7 \left(5 \left(4 e^{10 \left(x-\frac{y}{100}\right)}-1\right)\right)}
I think the equation is a text form.
Question:
I want to convert the equation to code form and want to plot the equation. (CTRL+E doesn't work)
Any help would be appreciated.

採用された回答

Shreyan Basu Ray
Shreyan Basu Ray 2022 年 1 月 1 日
編集済み: Shreyan Basu Ray 2022 年 1 月 1 日
Hey student_md,
You can use this work flow:
  1. Copy the Latex to Mathematica.
  2. Convert it to Mathematica expression, then convert the result to Matlab expression use ToMatlab package
> input=ToExpression["x \\frac{1}{y} \\sin(x) \\sqrt{ \\frac{2}{56}}",TeXForm]
>(*load the package*)
>Get["C\\ToMatlab.m"]
> ToMatlab[input]
gives (1/2).*7.^(-1/2).*x.*y.^(-1).*sin(x);
Refer to : ToMatlab.m link or download directly from this attached file.
I hope this helps you. :) Happy Matlabing !

その他の回答 (1 件)

dpb
dpb 2022 年 1 月 1 日
LaTeX is simply a display feature, at least so far it isn't tied to the actual code...
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 1 月 1 日
Also, mathematical presentation format such as LaTeX is often ambiguous as code, and needs to be interpreted according to the knowledge domain.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by