Effacer les filtres
Effacer les filtres

how to avoid the decimal values in fprintf

3 vues (au cours des 30 derniers jours)
jaah navi
jaah navi le 7 Fév 2019
Commenté : jaah navi le 7 Fév 2019
i want to display "1. particle index is 2"
"2. particle index is 2"
I tried with the followig command
fprintf('%3d. particle index is %5.4f\n',iteration,index)
But is displays "1. particle index is 2.0000"
"2. particle index is 2.0000"
Could anyone help me how to make it to 2 instead of 2.0000

Réponse acceptée

madhan ravi
madhan ravi le 7 Fév 2019
Use %d instead of %5.4f
  3 commentaires
madhan ravi
madhan ravi le 7 Fév 2019
It's always a good idea to look through the documentation https://www.mathworks.com/help/matlab/ref/fprintf.html if something is unclear. Spend some time that's all it takes.
fprintf('%3d. global fitness is %5.4f and index is %d\n',iteration,global_fitness,index)
jaah navi
jaah navi le 7 Fév 2019
ok.Thanks.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multicore Processor Targets dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by