フィルターのクリア

how to write a fraction in xlabel.

590 ビュー (過去 30 日間)
Shan  Chu
Shan Chu 2016 年 3 月 5 日
コメント済み: Simon Keegan 2023 年 4 月 13 日
dear all, I want to write a fraction a over b in the xlabel. How to do that? thanks
if true
%
figure (1)
fig =figure(1);
plot(t,real(y)'-x')
title('Mutual inductance M at frequency of 0.159 GHz','FontSize',18,'FontWeight','bold')
xlabel ??????????????????????????????????????????????????????????????????????????????????????????
ylabel('Inductance (nH)','FontSize',18,'FontWeight','bold')
set(fig,'position',[500 300 800 600]);
grid on
end
  3 件のコメント
Panagiotis Papias
Panagiotis Papias 2022 年 9 月 5 日
I wanted to take a moment and thank you for this comment, now I feel that is nicer latex being able to be used as an "add on" in Matlab.
Lars Abrahamsson
Lars Abrahamsson 2023 年 4 月 12 日
I miss the possibility to write
xlabel('$\displaystyle\frac{\text{W}}{\text{h}}$','interpreter','latex')
for example. But that is not possible it seems. Mathematical font is not wanted for "Watt per hour" for example.

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2016 年 3 月 5 日
The easy way:
xlabel('^{a}/_{b}')
The more difficult way requires you to call the 'latex' interpreter and use LaTeX commands. See the link for the LaTeX documentation.

その他の回答 (1 件)

Reko Hynönen
Reko Hynönen 2017 年 9 月 18 日
An old topic, but I've got an improved answer.
Star Strider's answer will work but it will look a bit silly. But like they suggest, you could use LaTeX interpreter instead.
Using LaTeX interpreter, you could accomplish this by writing:
xlabel('$\frac{a}{b}$','Interpreter','latex')
\frac{a}{b} is a LaTeX syntax for fractions. It will write 'a' to the numerator and 'b' to denominator. '$' symbols at the beginning and the end are necessary to interpret the expression in LaTeX Math mode, that interprets \frac correctly.
  10 件のコメント
Lars Abrahamsson
Lars Abrahamsson 2023 年 4 月 12 日
@Simon Keegan Actually, I think I found something like a solution
xlabel('Discharge $\displaystyle \frac{\rm m^3}{\rm s}$', 'Interpreter','latex')
Simon Keegan
Simon Keegan 2023 年 4 月 13 日
Great @Lars Abrahamsson. In MatLab Answers we trust! :)
Maybe I'll have a similiar case in future

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by