remove decimals from title when using sprintf

I have this to my figure
Q=2021; %year
plot(x,y)
title(sprintf('text %f',Q))
But the title is
text 2021.00000000
How do I remove the decimals?

 採用された回答

Les Beckham
Les Beckham 2023 年 4 月 11 日

0 投票

Q=2021; %year
x = 0:10;
y = x.^2;
plot(x,y)
grid on
title(sprintf('text %d',Q)) % <<< replace %f with %d

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLabels and Annotations についてさらに検索

製品

リリース

R2023a

質問済み:

2023 年 4 月 11 日

回答済み:

2023 年 4 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by