Matlab中unique函数和tabulate函数的区别

C = unique(A) returns the same data as in A, but with no repetitions. C is in sorted order.

>> unique([1 2 4 4 3 4])

ans =

1 2 3 4

tbl = tabulate(x) creates a frequency table of data in vector x. Information in tbl is arranged as follows:

  • 1st column — The unique values of x

  • 2nd column — The number of instances of each value

  • 3rd column — The percentage of each value

>> tabulate([1 2 4 4 3 4])
Value Count Percent
1 1 16.67%
2 1 16.67%
3 1 16.67%
4 3 50.00%

posted @ 2017-12-05 00:32  ystwyfe  阅读(3015)  评论(0编辑  收藏  举报