MATLAB Answers

How to find if a vector has a repetitive element or not? And its repetition number

3 views (last 30 days)
IBM watson
IBM watson on 23 Oct 2018
Edited: IBM watson on 23 Oct 2018
For example
A=[ 1 3 1 1 2 3 5]

Accepted Answer

Torsten
Torsten on 23 Oct 2018
Edited: Torsten on 23 Oct 2018
[a,b] = histc(A,unique(A));
count = a(b)
returns the number of occurences of each element in vector A in array "count".
Best wishes
Torsten.

  2 Comments

IBM watson
IBM watson on 23 Oct 2018
Actually i want to use your code for this:
https://www.mathworks.com/matlabcentral/answers/425580-setdiff-comand-usage?s_tid=mlc_ans_email_view#answer_342895

Sign in to comment.

More Answers (0)

Sign in to answer this question.