MATLAB: How to remove repeating elements from an array

matrixrepeating element

Hi Guys,
I have two matrices X and Y of the same size. Each element in Y has a corresponding element in X. There are some repeating values in X (and correspondingly in Y as well). Is there any way to remove these elements from the matrices.
Thanks, NS

Best Answer

Hi NS,
Ok. Now I understand what you want. ok. There is a way to do this. Take a look at the code below :
a = randi(10,[1,20]);
[b,m1,n1] = unique(a,'first');
[c1,d1] =sort(m1);
b = b(d1);
In this way your problem is solved. similarly you can also do so for the other matrix. Hope this helps...
Happy to help
UJJWAL
Related Question