首先要掌握一些latex语法,包括常用数学符号、希腊字母、分式等的书写方法
其次字符串中的数学公式要用一对'$$'包括起来,最后注意设置参数Interpreter为Latex。
看下面的例子:
x = linspace(-3,3);
y = sin(x);
plot(x,y)
y0 = x;
hold on
plot(x,y0)
y1 = x - x.^3/6;
plot(x,y1)
hold off
str = '$$\sin(x) = \sum_{n=0}^{\infty}{\frac{(-1)^n x^{2n+1}}{(2n+1)!}}$$';
text(-2,1,str,'Interpreter','latex')
h=legend('$$\sin(x) $$', '$$ y=x $$', '$$ y=x-{\frac{x^3}{6}} $$');
set(h,'Interpreter','latex');
xlabel({'$\int_0^x\!\int_y dF(u,v)$'},'Interpreter','latex');
title('$$ \sqrt{x^2+y^2}$$','Interpreter','Latex');
本回答被网友采纳