How to use latex's \mathcal{Z} in the axis labels of a Matlab figure?

조회 수: 51 (최근 30일)
Erez
Erez 2018년 4월 12일
댓글: Aryan Ritwajeet Jha 2023년 8월 7일
How to use latex's \mathcal{Z} in the axis lables of a Matlab figure?

답변 (1개)

M
M 2018년 4월 12일
title('$\mathcal{Z}$','Interpreter','latex')
  댓글 수: 4
M
M 2018년 4월 12일
Yes, sorry. I did it for the title but you can use it for x or y label.
Aryan Ritwajeet Jha
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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by