Ones Function Giving Me Decimal Points

12 ビュー (過去 30 日間)
Victoria Drapal
Victoria Drapal 2020 年 4 月 20 日
コメント済み: Victoria Drapal 2020 年 4 月 20 日
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

採用された回答

Steven Lord
Steven Lord 2020 年 4 月 20 日
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
  1 件のコメント
Victoria Drapal
Victoria Drapal 2020 年 4 月 20 日
Thank you!!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by