MATLAB Answers

How to find out whether there is a repetitive element in the columns of a matrix?

1 view (last 30 days)
IBM watson
IBM watson on 17 Apr 2019
Commented: IBM watson on 17 Apr 2019
a=[ 1 2 3
4 2 1
1 4 2]
Bold ones are that what I am looking for. There is no need for imformation about their indexes. I just want to know whether there is or not.
Thank you.


Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 17 Apr 2019
for k = 1:size(a,2)
Repetitions_in_columns % 1 means yes 0 means no each

More Answers (1)

Stephen Cobeldick
Stephen Cobeldick on 17 Apr 2019
"I just want to know whether there is or not."
>> any(diff(sort(a,1),1)==0,1)
ans =
1 1 0


Community Treasure Hunt

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

Start Hunting!

Translated by