how to manage Fraction format problem

1 回表示 (過去 30 日間)
skysky2000
skysky2000 2017 年 1 月 30 日
コメント済み: skysky2000 2017 年 1 月 30 日
Dear all, I have vector with numbers and fraction. How can I reduce fraction number.?for example a=[1.23456789 6.14521456 7.906342678 10.47609352]
expect results should be: re=[ 1.2 6.1 7.9 10.4] Thanks...

採用された回答

the cyclist
the cyclist 2017 年 1 月 30 日
編集済み: the cyclist 2017 年 1 月 30 日
One way to display a decimal number to one decimal place:
sprintf('%5.1f',a)
Note that this will not change the value stored in a; it will only display it differently.
  3 件のコメント
the cyclist
the cyclist 2017 年 1 月 30 日
編集済み: the cyclist 2017 年 1 月 30 日
If you want to store a value that is changed, use the round function:
re = round(a,1)
Or you might want fix instead.
skysky2000
skysky2000 2017 年 1 月 30 日
That amazing 100% work..... thanks alots

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2017 年 1 月 30 日
See the second input of the round function.

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by