Effacer les filtres
Effacer les filtres

How to keep decimal float point only

3 vues (au cours des 30 derniers jours)
JZ
JZ le 3 Fév 2021
Commenté : JZ le 3 Fév 2021
I could not find any answer about this. So I have a float number (a=323.153), I wanna output look like this with keeping decimal point only:
>> a=323.
What format shall I use?
Thanks.

Réponse acceptée

Robert U
Robert U le 3 Fév 2021
If it is just for display you can specify the output format in fprintf.
a = 323.153;
fprintf('<< a = %.0f.\n',a)
output:
<< a = 323.
Kind regards,
Robert
  1 commentaire
JZ
JZ le 3 Fév 2021
Thanks, Robert!

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 3 Fév 2021
https://www.mathworks.com/help/matlab/ref/fix.html
  2 commentaires
JZ
JZ le 3 Fév 2021
Thanks, Walter.
It's not exactly what I need. I need output with a dot, so (>>a=323.).
Alex Alex
Alex Alex le 3 Fév 2021
Convert to string format and add point manually?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Tags

Produits


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by