![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1167443/image.png)
convert Matlab results to Latex
130 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
M
am 24 Okt. 2022
Beantwortet: Steven Lord
am 25 Okt. 2022
Hi all, I obtained some equations in Matlab's command window, and I have to write them in Latex, but because they are too long and hard to follow, I would like to know if there is any way to convert them directly to Latex. Please see the below formula. Thanks in advance for any help.
Dhf1=(c.^8.*kipr.*vplc.^2.*(ct.*gamma - c.*(gamma + 1)))./(ki.^2.*(kb.*kp.^2.*(c.^4 + kc.^4 - (c.^4.*kh.^4)./(c.^4 + kh.^4)) + (c.^8.*h.*vplc.^2.*(kb + 1))./(ki.^2.*(c.^2 + kplc.^2).^2)).*(c.^2 + kplc.^2).^2) - (c.^16.*h.*kipr.*vplc.^4.*(ct.*gamma - c.*(gamma + 1)).*(kb + 1))./(ki.^4.*(kb.*kp.^2.*(c.^4 + kc.^4 - (c.^4.*kh.^4)./(c.^4 + kh.^4)) + (c.^8.*h.*vplc.^2.*(kb + 1))./(ki.^2.*(c.^2 + kplc.^2).^2)).^2.*(c.^2 + kplc.^2).^4);
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Okt. 2022
Not exactly.
I can tell from the .^ that what you are showing is MATLAB code, not the output of the Symbolic Toolbox. There is no function provided that can convert from MATLAB code to Latex.
However if you have the Symbolic Toolbox, then
eqn = 'Dhf1=(c.^8.*kipr.*vplc.^2.*(ct.*gamma - c.*(gamma + 1)))./(ki.^2.*(kb.*kp.^2.*(c.^4 + kc.^4 - (c.^4.*kh.^4)./(c.^4 + kh.^4)) + (c.^8.*h.*vplc.^2.*(kb + 1))./(ki.^2.*(c.^2 + kplc.^2).^2)).*(c.^2 + kplc.^2).^2) - (c.^16.*h.*kipr.*vplc.^4.*(ct.*gamma - c.*(gamma + 1)).*(kb + 1))./(ki.^4.*(kb.*kp.^2.*(c.^4 + kc.^4 - (c.^4.*kh.^4)./(c.^4 + kh.^4)) + (c.^8.*h.*vplc.^2.*(kb + 1))./(ki.^2.*(c.^2 + kplc.^2).^2)).^2.*(c.^2 + kplc.^2).^4)';
symeqn = str2sym(eqn)
latex(symeqn)
Unfortunately there is no method provided to take that dynamic output and display it in formatted form.
If you happen to be using LiveScript, then what I show here as symeqn would be automatically displayed nicely -- same as what you see here in this Answer. (There is also a sympref() to disable abbreviating the expression by moving
out to a separate expression on display.)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1167443/image.png)
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu LaTeX finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!