num2str with latex

조회 수: 7 (최근 30일)
Marisabel Gonzalez
Marisabel Gonzalez 2018년 12월 17일
편집: Luna 2021년 3월 22일
Hi, so I have this label which works fine. However, I've created a function in which the exponent varies (1/4). Therefore, I put a variable m in there and used num2str but the label doesn't come up right....
How could I apply num2str in the exponent for this case?
xlabel('$\it{\bf{(f_{ohm}P)^{1/4}}}$','Interpreter','Latex','FontSize', 15 )
  댓글 수: 2
Luna
Luna 2018년 12월 17일
share the code part of using num2str. What kind of result you are expecting?
Marisabel Gonzalez
Marisabel Gonzalez 2018년 12월 17일
This is what comes out...
Screen Shot 2018-12-17 at 12.20.56.png
m5 = 1/4;
xlabel(['$\it{\bf{(f_{ohm}P)^{num2str(m5)}}}$','Interpreter','Latex','FontSize', 15 ])
ylabel('$\it{\bf{\Lambda^{1/2}}}$','Interpreter','Latex','FontSize', 15 )
This is what I want
Screen Shot 2018-12-17 at 12.18.30.png

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

채택된 답변

Luna
Luna 2018년 12월 17일
You can use rats function to get what you need actually.
Try this below:
m = 1/4;
a = ['$\it{\bf{(f_{ohm}P)^{',rats(m), '}}}$'];
xlabel(a,'Interpreter','Latex','FontSize', 15 );
  댓글 수: 2
Tianyu Fan
Tianyu Fan 2021년 1월 24일
Luna, what should I do if ‘m’ is a decimal?
Luna
Luna 2021년 3월 22일
편집: Luna 2021년 3월 22일
If you define m = 0.25, you will see rats function still works as 1/4.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by