필터 지우기
필터 지우기

using latex interpreter for multiple legends

조회 수: 7 (최근 30일)
Dharma Khatiwada
Dharma Khatiwada 2022년 3월 6일
편집: Awais Saeed 2022년 3월 7일
Hello,
I am trying to write legend in latex but I am missing something here. It says "String scalar or character vector must have valid interpreter syntax". Do I need to keep set (legend,'Interpreter', 'latex') after each lgds?
Thanks
Dharma
lgd1=['r_{th} = ' num2str(z1)];
lgd2=[', t_{tol}=t_{2}± ' num2str(z4*100)];
lgd3=[', K= ' num2str(z2)];
lgd4=['+' num2str(z3)];
lgd5=[', K_{ave}= ' num2str(z5)];
legend([lgd1 lgd2 lgd3 lgd4 lgd5])
set(legend,'Interpreter','latex');
set(legend,'FontSize',10);

답변 (1개)

Awais Saeed
Awais Saeed 2022년 3월 7일
편집: Awais Saeed 2022년 3월 7일
You do not need to specify interpreter as latex. Matlab uses some subset of Tex by default.
z = 5.213;
fplot(@(x) sin(x))
lgd1=['r_{th} = ' num2str(z*0.5)];
lgd2=[', t_{tol}= t_{2}± ' num2str(z*100)];
lgd3=[', \newline K= ' num2str(z*2)];
lgd4=['+' num2str(z*23)];
lgd5=[', K_{ave}= ' num2str(z*-1)];
legend([lgd1 lgd2 lgd3 lgd4 lgd5])
set(legend,'FontSize',10);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by