How to identify duplicate values in an n dimensional array , then club the linked values related to it in another array

1 view (last 30 days)
How to identify duplicate values in an n dimensional array , then club the linked values related to it in another array
for example
A= [ 1 8 10 4
1 8 4 0]
how to identify the repeated value and then club the value in another matrix B and set repeated values to null
  3 Comments
Jan
Jan on 17 Oct 2021
I have no idea, how B can be constructed based on A. You asked for duplicate elements in A. Now there is one 5 only in A, so why does 5 occur in B?Why is B 3x3 and not 9x1?

Sign in to comment.

Answers (1)

Jan
Jan on 17 Oct 2021
A = [ 1 8 10 4; ...
1 8 4 0];
T = isMultiple(A);
B = A(T) % ? or what do you want?
A(T) = 0;
function T = isMultiple(A)
[S, idx] = sort(A(:).');
m = [false, diff(S) == 0];
ini = strfind(m, [false, true]);
m(ini) = true; % Mark 1st occurence in addition
T(idx) = m;
end
  1 Comment
sakshi chopra
sakshi chopra on 17 Oct 2021
Thanks for the help , but this doesn't solve my problem. If possible please suggest some another solution, i have tried to clarify my problem again.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!