remove decimals from title when using sprintf

1 次查看(过去 30 天)
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
Q=2021; %year
x = 0:10;
y = x.^2;
plot(x,y)
grid on
title(sprintf('text %d',Q)) % <<< replace %f with %d

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by