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

3 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Time Series 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by