How to convert something from Latex to matlab, is there a specific way where i can convert it with ease from latex to matlab, some function? please help
Mostra commenti meno recenti
is there a specific way where i can convert it with ease from latex to matlab
an example of an equation i want to know how can i write it in matlab form from latex
example 1:
\begin{equation} h_{k}=\frac {A(m+1)}{2 \pi d_{k}^{2}}\cos ^{m}(\phi _{k})T(\psi _{k})g(\psi _{k})\cos (\psi _{k}), \end{equation}
example 2:
\begin{align} \tilde {R}_{k \rightarrow j}\!=\! \begin{cases} \!\! \frac {B}{2} \log _{2}\left ({1 + \frac {\left ({ h_{k} a_{j} }\right )^{2}} {\sum _{i=j+1}^{K}\left ({ h_{k} a_{i} }\right )^{2} + \varepsilon \sum _{i=1}^{j-1}\left ({ h_{k} a_{i} }\right )^{2}+ 1/\rho } }\right ) \geq T_{j},\\ \qquad j \leq k,j \neq K;\\ \!\! \frac {B}{2}\log _{2} \left ({\! 1\!+\!\frac {\left ({ h_{K} a_{j} }\right )^{2}} {\varepsilon \sum _{i=1}^{j-1}\left ({ h_{K} a_{i} }\right )^{2}+1/\rho }}\right ) \!\geq \! T_{j} , \quad j=k=K;\end{cases}\!\!\!\!\!\!\!\notag \\ {}\end{align}
Risposte (2)
Ameer Hamza
il 10 Apr 2020
0 voti
MATLAB only supports conversion from symbolic to latex, not the other way around. You will need to write those equations in MATLAB manually.
An indirect approach is pointed out by Walter: https://www.mathworks.com/matlabcentral/answers/174592-how-to-convert-latex-representation-to-symbolic-math. For that, you will first need to use Wolfram alpha to convert the latex to mathematical form and then paste it into MATLAB.
4 Commenti
Sultan Al Harthy
il 10 Apr 2020
Ameer Hamza
il 10 Apr 2020
I tried wolfram alpha with your first latex expression: https://www.wolframalpha.com/input/?i=h_%7Bk%7D%3D%5Cfrac+%7BA%28m%2B1%29%7D%7B2+%5Cpi+d_%7Bk%7D%5E%7B2%7D%7D%5Ccos+%5E%7Bm%7D%28%5Cphi+_%7Bk%7D%29T%28%5Cpsi+_%7Bk%7D%29g%28%5Cpsi+_%7Bk%7D%29%5Ccos+%28%5Cpsi+_%7Bk%7D%29
even wolfram alpha is not able to convert complex latex expressions into mathematical equations. Your best bet is to write them manually.
Sultan Al Harthy
il 10 Apr 2020
Ameer Hamza
il 10 Apr 2020
Glad to be of help.
Duncan Carlsmith
il 29 Lug 2024
0 voti
CHATGPT will do it. You there are other options and could even call the API within your code to do it programmatically. See e.g. https://www.mathworks.com/matlabcentral/fileexchange/126500-translate-latex-to-matlab-with-chatgpt?
and some of my other File Exchange submissions so say convert it to Turkish or whatever.
Categorie
Scopri di più su LaTeX in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!