convert Matlab results to Latex
215 次查看(过去 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.)
更多回答(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!