Path: news.mathworks.com!not-for-mail
From: "Liqing" <liqingj@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: ismember question
Date: Thu, 25 Mar 2010 19:18:05 +0000 (UTC)
Organization: 400 Riverbend Pkwy Apt 8
Lines: 30
Message-ID: <hogctd$f92$1@fred.mathworks.com>
References: <hogaic$4go$1@fred.mathworks.com> <hogcei$75k$1@fred.mathworks.com>
Reply-To: "Liqing" <liqingj@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1269544685 15650 172.30.248.35 (25 Mar 2010 19:18:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 25 Mar 2010 19:18:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1014951
Xref: news.mathworks.com comp.soft-sys.matlab:620358

That absolutely solved my problem!!!

Thank you so much, Roger.

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hogcei$75k$1@fred.mathworks.com>...
> "Liqing" <liqingj@gmail.com> wrote in message <hogaic$4go$1@fred.mathworks.com>...
> > I have two n by 5 matrixes, like below:
> > 
> > % The 5 columns are SiteNum, Year, Month, Day, Value, respectively.
> > M = [ 31007 1955 2 15 7.8;
> >          31007 1955 2 16 7.1;
> >          31007 1955 3  7  8.8;
> >          31025  1956 1  2  7.6;
> >          31025  1956  1  5  9.5
> >          ...];
> > 
> > N = [31007 1955 2  15 256;
> >        31007 1955 3  7  467;
> >        31025  1956  1  2  105;
> >        32048  1957  5  9  67
> >          ...];
> > 
> > I will need to generate a third 6-column matrix with SiteNum, Year, Month, Day, Value1, Value2. Value1 and Value2 are from the M(:,5) and N(:,5), respectively. They have to share the same SiteNum, Year, Month, Day, so that I can do the further calculation. 
> > 
> > Anyone can help me? Thank you in advance
> 
>   Apply the intersect function to M(:,1:4) and N(:,1:4) using the 'rows' option, and use the resulting index vector to get your desired result.
> 
> Roger Stafford
> .