How to use latex's \mathcal{Z} in the axis labels of a Matlab figure?
78 次查看(过去 30 天)
显示 更早的评论
How to use latex's \mathcal{Z} in the axis lables of a Matlab figure?
0 个评论
回答(1 个)
M
2018-4-12
title('$\mathcal{Z}$','Interpreter','latex')
4 个评论
Aryan Ritwajeet Jha
2023-8-7
If you use sprintf command (for inputting some variable values in the string, you need to put another escape character \ for MATLAB to recognize commands like \mathcal{} ,\in{}, etc.
x = 1:5;
y = sin(x);
plot(x, y);
% regular string does NOT need nother escape character
% xLabel = "t \in [1, 5], t \in \mathcal{N}";
% sprintf needs another escape character
xLabel = sprintf("t \\in [%d, %d], t \\in \\mathcal{N}", x(1), x(end));
xlabel(strcat("$", xLabel, "$"), 'Interpreter', 'latex');
yLabel = "sin(t)";
ylabel(strcat("$", yLabel, "$"), 'Interpreter', 'latex');
titleStr = strcat("$\sin(t)$", " for ", "$", xLabel, "$");
title(titleStr, 'Interpreter', 'latex')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!