gogi1000
Newbie level 2
- Joined
- Jan 20, 2014
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 13
i have matrix C9x9 from real numbers. i need to make program in matlab which checking duplicates above main diagonal,if there're i must print first duplicate value that is found and searching break, if there're not i must print message 'no duplicates'.
i have some code, but this code compare elements above main diagonal with elements under main diagonal. How comparing elements above main diagonal with in range above main diagonal or with in range all matrix?
i have some code, but this code compare elements above main diagonal with elements under main diagonal. How comparing elements above main diagonal with in range above main diagonal or with in range all matrix?
Code:
A = [1 3 2; 4 5 1; 3 1 1]
A_unique = unique(tril(A, -1));
FLAG = false;
for ii = 1:length(A(1,:))
for jj = ii+1:length(A(1,:))
if (length(A_unique) == length(unique([A_unique; A(ii,jj)])))
display(A(ii,jj))
FLAG = true;
break;
end
end
if ~FLAG
display('no duplicates')
end
end