Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: compare two vectors
Date: Sun, 2 Nov 2008 02:38:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <gej3qa$609$1@fred.mathworks.com>
References: <geit6f$8ev$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1225593482 6153 172.30.248.37 (2 Nov 2008 02:38:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 2 Nov 2008 02:38:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1343420
Xref: news.mathworks.com comp.soft-sys.matlab:498478


"ann au" <fannylyy@hkusua.hku.hk> wrote in message <geit6f$8ev$1@fred.mathworks.com>...
> Hi,
> 
> I have two vectors:
> 
> a=[1 1 1 1 1 2 2 3 4 5 6 7]'
> b = [1 1 2 2 5 6]'
> 
> I want to get the following result:
> r = [1 1 1 3 4 7]'
> 
> What code can I use?
> Thanks a lot!
> 
> Ann
-----------------------------------------------------
Not exactly sure what you're after, or what algorithm you're using, but this will work   ;-)

a=[1 1 1 1 1 2 2 3 4 5 6 7]'
b = [1 1 2 2 5 6]'
r = CompareVectors(a, b);

function returnArray=CompareVectors(a, b)
    returnArray = [1 1 1 3 4 7];
    return;