Clear Filters
Clear Filters

How can I count the number of vector elements without repetition?

3 views (last 30 days)
Hi, I have a vector that contains repeated elements, How can I count the number of vector elements without repetition?
For example: a=[2 5 2 8 9 8 7 8 1]; I expect the result will be: count = 6

Accepted Answer

dpb
dpb on 11 Nov 2016
>> na=[2 5 2 8 9 8 7 8 1];
>> length(unique(na))
ans =
6
>>

More Answers (0)

Categories

Find more on Time Series in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!