LaTeX interpreter is not working correctly with code including subscripts in Control System Toolbox legends

조회 수: 14 (최근 30일)
When running the following code:
G1 = tf(1,[1,1,1]);
G2 = tf(1,[1,0.5,1]);
step(G1,G2);
h = legend('$G_1(s)$','$G_2(s)$');
h.Interpreter = "latex";
h.FontSize = 12;
We can observe that the subscripts are not displayed correctly in the legend. I would appreciate any solution for this bug. Thanks!

답변 (1개)

Steven Lord
Steven Lord 2022년 8월 8일
This is Not a Bug. In LaTeX, A_bc will only treat b as a subscript. In order to include multiple symbols in a subscript (or superscript) you need to group them with curly braces.
For instance, here is A_bc: while here is A_{bc}: .
  댓글 수: 2
Adolfo Hilario
Adolfo Hilario 2022년 8월 8일
Thanks for your answer, but that is not the problem. Please, look at the code and the results: you will see that no subscript is displayed, nor even the first one (an underscore is displayed instead). So, yes, it is a bug of the Control System Toolbox.
Adolfo Hilario
Adolfo Hilario 2022년 8월 8일
In fact, there is a way to solve this: plotting something into the figure before and overwriting the legend:
figure; hold on;
plot(0,0);
plot(0,0);
G1 = tf(1,[1,1,1]);
G2 = tf(1,[1,0.5,1]);
stepplot(G1,G2);
h = legend('$G_1(s)$','$G_2(s)$');
h.Interpreter = "latex";
h.FontSize = 12;
You can see that the subscripts are correctly displayed now.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by