Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: repeating elements and their corresponding

$
0
0
On 5/27/2013 2:16 PM, ali wrote:
> Hi Guys,
>
> I have two vectors X and Y of the same size. Each element in Y has a
> corresponding element in X. There are some repeating values in X . Is
> there any way to remove these elements from the vector X and remove
> their corresponding elements inY.
>
> e.g if X=[1,2,3,4,4,5,5,6], and Y=[2,5,7,8,9,4,3,6]
> So I need
> X=[1,2,3,4,5,6], and Y=[2,5,7,8,4,6]

 >> [~,ix]=unique(X,'first');
 >> Z=[X(ix)' Y(ix)']
Z =
      1 2
      2 5
      3 7
      4 8
      5 4
      6 6
 >>

doc unique

--

Viewing all articles
Browse latest Browse all 19628

Trending Articles