Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: help with unique function
Date: Wed, 5 May 2010 17:53:04 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 45
Message-ID: <hrsba0$bj3$1@fred.mathworks.com>
References: <hrrgbg$mk0$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1273081984 11875 172.30.248.38 (5 May 2010 17:53:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 5 May 2010 17:53:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:632855

"Fraser Dickson" <fraser.dickson@gmail.com> wrote in message <hrrgbg$mk0$1@fred.mathworks.com>...
> Hi im trying to use the uniqie function to get rid of duplicate entries within my array but im having some trouble with it.
> 
> I have a 2d array always with 2 cols
> 
> I want to only perofrm the unique function to col2 but always delete the corresponding value in that row form col 1
> 
> eg.
> 
> a = [ 2,23 ; 3,25; 4,23; 5,25; 6,26 ;7,23 ; 8,27 ; 9,28 ; 10,29]
> 
> i want b to equal what i have mentioned  above which should hopefully give me
> 
> b = [2,23 ; 3,25 ; 6,26 ; 8,27 ; 9,28 ; 10,29]
> 
> a = unique(b) does not do this ?
> 
> Can someone help me out ?

one of the many other solutions

     a=[
          2    23
          3    25
          4    23
          5    25
          6    26
          7    23
          8    27
          9    28
         10    29
     ];
     [ax,ax,ax]=unique(a(:,2));
     [ax,ax]=unique(ax,'first');
     r=a(ax,:)
%{
     2    23
     3    25
     6    26
     8    27
     9    28
    10    29
%}

us