How do you round up or down to a decimal
114 ビュー (過去 30 日間)
古いコメントを表示
I want to round UP to a specific decimal location (tenths in my current need).
a = 6.234;
b = round( a, 1);
gives 6.2. It works, but is not UP. It rounded DOWN. So I add TieBreaker:
b = round( a, 1, TieBreaker="plusinf");
gives
Error using round
Too many input arguments.
I missed something
b = round( a, TieBreaker="plusinf");
gives
Error using round
Third input must be either 'decimals' or 'significant'.
I missed something
Any comments, corrections, alternate methods are appreciated.
0 件のコメント
採用された回答
Image Analyst
2023 年 1 月 2 日
編集済み: Image Analyst
2023 年 1 月 2 日
その他の回答 (1 件)
John D'Errico
2023 年 1 月 2 日
編集済み: John D'Errico
2023 年 1 月 2 日
You are trying to use capabilities of round that are not present in your (older) MATLAB release.
For that code to work, you need to upgrade to a current release. But a simple call to round should still work for you.
b = round(6.234,1)
c = round(6.253,1)
Just that the option you are trying to use is a more recent capability.
3 件のコメント
John D'Errico
2023 年 1 月 2 日
I am constantly being surprised, since I too often forget to read the release notes for every release.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!