如何确定table中数字的位数

How to determine the number of digits of a number in a table

我正在尝试确定 table 中某个数字的位数。例如,如果我有这样的 table:

   4    200   50  1236
  69     54  285     1
1458      2   69   555

答案是

1 3 2 4
2 2 3 1 
4 1 2 3

我以前可以用这段代码做到这一点

strlength(num2str(ADCPCRUM2(i,2)))

但后来我输入的是数字,而不是 table。

如何确定 table 中数字的长度?

floor(log10(A)) 这样做。 log10() 基本上计算数字的个数 before/behind 最重要数字所在的小数点分隔符。

在 table 上使用它时,只需调用 table2array() 即可解决问题。

警告: 这仅适用于整数;对于 non-integer 个输入,它会涉及更多。