![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1167443/image.png)
convert Matlab results to Latex
조회 수: 160 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2022년 10월 24일
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)
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 LaTeX에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!