Eliminate decimals past the thousandths place in a table

5 ビュー (過去 30 日間)
camicat
camicat 2020 年 1 月 20 日
編集済み: camicat 2020 年 1 月 22 日
I have a table being pulled from a database that contains 'string' and 'double' data that being a parameter name and it's associated limits. I am currently trying to eliminate replicate data using the unique function however some of the data that is considered duplicated is not removed because it has either 14 or 16 trailing zeros. I would like to eliminate the zeros past the thousandths place.
Fix, Ceil, Round, and Floor do not work with tables.
  3 件のコメント
Adam Danz
Adam Danz 2020 年 1 月 21 日
編集済み: Adam Danz 2020 年 1 月 21 日
If those values are considered unique by the unique() function that eliminates the possibility that you're just using a long format such as
format long
but if those values are numeric, it suggests that they have some trailing non-zero decimal values, otherwise they wouldn't end in a string of 0s.
You could round all of your values to the thousandths place by using
round(x,3)
Image Analyst
Image Analyst 2020 年 1 月 21 日
Adam, can you post it down below in the Answers section?

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

採用された回答

Adam Danz
Adam Danz 2020 年 1 月 21 日
If those values are considered unique by the unique() function that eliminates the possibility that you're just using a long format such as
format long
but if those values are numeric, it suggests that they have some trailing non-zero decimal values, otherwise they wouldn't end in a string of 0s.
You could round all of your values to the thousandths place by using
round(x,3)
  6 件のコメント
Walter Roberson
Walter Roberson 2020 年 1 月 22 日
uniquetol()
Adam Danz
Adam Danz 2020 年 1 月 22 日
Yeah, I'd try Walter's suggestion first by replacing the unique function my previous comment with uniquetol. If that doesn't work, you could play around with tolerance level. See C = uniquetol(A,tol)
If all else fails, you can round that column of data using
T.Var = round(T.Var,3);
where T is your table and var is the column's variable name.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by