Show matlab code equation in mathtype or pdf or latex format

13 次查看(过去 30 天)
Hello!
Once I have entered an equation in matlab is there a way to "see" it in another format just to double check if I entered it correctly? I mean, if I have an equation that looks messy like the following for example:
f(2)=-(b+1)*y+d+g*n*(x2.^a*y.^(1-a)*p.^a-(1./z)*x2-ff-s)+(1-g)*n*((1-a)./(a*h).^(a./(a-1))*y*p.^(a./(1-a))-ff);
  1 个评论
Ruben Jimenez
Ruben Jimenez 2020-7-6
Try this:
syms b y d p ff s g n x2 x1 a z h
f(2)=-(b+1)*y+d+g*n*(x2.^a*y.^(1-a)*p.^a-(1./z)*x2-ff-s)+(1-g)*n*((1-a)./(a*h).^(a./(a-1))*y*p.^(a./(1-a))-ff);
pretty(f)

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2015-9-13
Symbolic expressions (only) are automatically "pretty-printed", and for symbolic expressions only you can use the latex() command to convert them to LaTeX format.
I do not immediately see any routine or file contribution to convert MATLAB code to LaTeX, but there might be one somewhere.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by