How can I count frequency of 3D plot in Matlab?

Viewed 50

I have list of 3D points (x,y,z) in each vector.

matrix[4535x3] = [3,4,2; 3,5,3; 4,5,2; 4,7,6; ...]

I would like to count frequency of each 3D point. For example,

[frequency_count] = function([4535x3 3d(x,y,z) points])

[4;        [3,5,4;
 4;         5,4,4;
 6;    <=   2,5,4;
 .          .
 .          .
 . ]        .     ]

Is there any functions that can count 3d points in matlab? if not how can I do this?

1 Answers

I haven't tested this, but I believe you can use unique with three outputs like this:

[unique_points, ia, ic] = unique(matrix, 'rows');

Then, use accumarray on ic like this:

frequency_count = accumarray(ic,1);
point_count = [unique_points, frequency_count];
Related