フィルターのクリア

how to use sprintf for xticklabel?

2 ビュー (過去 30 日間)
MP
MP 2022 年 8 月 15 日
コメント済み: MP 2022 年 8 月 15 日
how to print
a = 0.1005:0.1:1.1005
as, 0.1, 0.2, 0.3, ... 1.0 for tickllabes?
I used sprintf command but the optput is not as expected.
ytl = sprintf('%.2f', 0.1005:0.1:1.1005);
ytl
0.100.200.300.400.500.600.700.800.901.001.10
How to give this as input to xticklabels?

採用された回答

Chunru
Chunru 2022 年 8 月 15 日
x = 0.1005:0.1:1.1005;
y = randn(size(x));
plot(x, y)
grid
% for x tick format
xtickformat('%.2f')
% Conversion of array to char array
ytl = sprintf('%.2f\n', 0.1005:0.1:1.1005)
ytl =
'0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00 1.10 '
  5 件のコメント
Chunru
Chunru 2022 年 8 月 15 日
編集済み: Chunru 2022 年 8 月 15 日
See above for using sprintf. Beware that you may lose the precision of xtick label.
MP
MP 2022 年 8 月 15 日
YES!!! magical...
That worked..
Thank you so very much...

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by