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일
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 Exchange에서 Labels 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