フィルターのクリア

Unable to format fractions in xticklabels

4 ビュー (過去 30 日間)
Brilliant Purnawan
Brilliant Purnawan 2020 年 11 月 7 日
コメント済み: Ameer Hamza 2020 年 11 月 7 日
Hi, so I'm trying to write a fraction in 'xticklabels', I already tried to write
$\frac{a}{b}$
but it doesn't seem to work, any suggestions? Code section is given below:
figure(2);
plot(y(:,3),y(:,4));
xticks([-pi -3*pi/4 -pi/2 -pi/4 0 pi/4 pi/2 3*pi/4 pi])
xticklabels({'-\pi','$\frac{-3\pi}{4}$','-\frac{\pi}{2}','-\pi/4','0','\pi/4','\pi/2','3\pi/4','\pi'})
title('Angular Velocity Graph')
xlabel('Angle (rad)')
ylabel('Angular Velocity (rad s^{-1})')

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 7 日
You need to use latex interpreter. Following shows how to do that
figure(2);
ax = axes();
plot(y(:,3),y(:,4));
xlim([-pi pi])
xticks([-pi -3*pi/4 -pi/2 -pi/4 0 pi/4 pi/2 3*pi/4 pi])
xticklabels({'$-\pi$','$\frac{-3\pi}{4}$','$-\frac{\pi}{2}$','$-\pi/4$','$0$','$\pi/4$','$\pi/2$','$3\pi/4$','$\pi$'})
ax.XAxis.TickLabelInterpreter = 'latex';
title('Angular Velocity Graph')
xlabel('Angle (rad)')
ylabel('Angular Velocity (rad s^{-1})')
  2 件のコメント
Brilliant Purnawan
Brilliant Purnawan 2020 年 11 月 7 日
Cheers, it worked perfectly
Ameer Hamza
Ameer Hamza 2020 年 11 月 7 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePlot Customization についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by