没有出现带有 LaTeX 的 Matlab 图标题?

Matlab figure title w/ LaTeX not appearing?

我正在尝试使用 LaTeX 标记我的绘图。我有两个问题:我的标题不会显示,我需要向 LaTeX 表达式添加文本。理想情况下,我希望它将我的数字标记为 "f(x) for different values of n",但我想要的不是 "f(x)":

如何将 "for different values of n" 部分添加到我的 LaTeX 表达式中,更重要的是,为什么我的标题没有首先显示?

这是我的脚本:

x = linspace(0, 1, 100);
y1 = sin(pi*x);
y2 = sin(2*pi*x);
y3 = sin(4*pi*x);
hold on
plot(x,y1,'color',1/255*[255 20 147],'LineWidth',2);
plot(x,y2,'color',1/255*[0 238 118],'LineWidth',2);
plot(x,y3,'color',1/255*[0 238 238],'LineWidth',2);
xlabel('\theta','FontSize',15);
ylabel('$f_{s}(\theta)$','Interpreter','LaTex','FontSize',15);
title('$f_{s}(\theta)=\sin (n\theta\pi)$','Interpreter','LaTex',FontSize',18);
legend('n = 1', 'n = 2', 'n = 4','Location','best')
hold off

本质上,FontSize 之前只缺少一个撇号。然后,标题确实出现了。要添加 non-math 文本,只需在 $ 符号后继续。

title('$f_{s}(\theta)=\sin (n\theta\pi)$  for different values of n','Interpreter','LaTex','FontSize',18);