Ones Function Giving Me Decimal Points
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Victoria Drapal
le 20 Avr 2020
Commenté : Victoria Drapal
le 20 Avr 2020
Hello!
I can't seem to figure out why the built-in function "ones" is giving me decimal points.
ex: >> ones(2)
ans =
1.00 1.00
1.00 1.00
0 commentaires
Réponse acceptée
Steven Lord
le 20 Avr 2020
You've turned on the 'bank' display format. That displays a double or single precision array with 2 decimal places regardless of whether it contains integer values or non-integer values.
format % short
A = ones(2) % no decimal places, none required to display A's contents
format bank
A = ones(2) % 2 decimal places
format long
A = ones(2) % no decimal places, none required
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!