Matlab中统计矩阵中相同元素的个数的方法

来源:互联网 发布:淘宝页头150px图片 编辑:程序博客网 时间:2024/05/18 20:32

方法一:

A = data(:,i);

B = unique(A);

c = zeros(size(B));
for i=1:length(B)
    c(i)=length(find(A==B(i)));
end

 

方法二:

使用函数tabulate(A)  

 

方法三:

使用函数hist(A,unique(A))



FROM:http://www.cnblogs.com/ysjxw/archive/2011/05/17/2048599.html

0 0