Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matrix matching
Date: Thu, 13 Aug 2009 19:21:02 +0000 (UTC)
Organization: Mitre Corp
Lines: 116
Message-ID: <h61p2u$f7k$1@fred.mathworks.com>
References: <h61k2i$p69$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 1250191262 15604 172.30.248.37 (13 Aug 2009 19:21:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 13 Aug 2009 19:21:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2318
Xref: news.mathworks.com comp.soft-sys.matlab:563194

"charles atlas" <mufasa1234555@yahoo.com> wrote in message <h61k2i$p69$1@fred.mathworks.com>...
> I have two data sets 
> A = 
> 1 23 345
> 1 45 636
> 1 65 672
> 2 26 985
> 2 86 350
> 3 34 452
> 3 98 768
> 3 56 665
> 3 39 445
> 4 34 678
> 5 65 123
> 5 17 435
> 5 78 198
> 6 23 234
> 6 44 760
> 
> B =
> 1 23 345
> 1 45 636
> 1 65 672
> 2 26 985
> 2 86 350
> 3 34 452
> 3 98 768
> 3 56 665
> 3 39 445
> 4 34 678
> 5 65 123
> 5 17 435
> 5 78 198
> 6 23 234
> 6 44 760
> 
> Obviously these two data sets are the same.
> However, sometimes I will have two data sets that are slightly off where A would have one two or three less rows than B or vice versa as shown:
> A = 
> 1 23 345
> 1 45 636
> 1 65 672
> 2 26 985
> 2 86 350
> 3 34 452
> 3 98 768
> 3 56 665
> 3 39 445
> 4 34 678
> 5 65 123
> 5 17 435
> 5 78 198
> 6 23 234
> 6 44 760
> 
> B =
> 1 23 345
> 1 45 636
> 2 26 985
> 2 86 350
> 3 34 452
> 3 98 768
> 3 56 665
> 4 34 678
> 5 65 123
> 5 17 435
> 5 78 198
> 6 23 234
> 6 44 760
> 
> What I would like to do is make it so that they have the same number of rows (possibly by inserting  a row of zeros)  anytime this problem occurs.
> Final result would look like this:
>  
> A = 
> 1 23 345
> 1 45 636
> 1 65 672
> 2 26 985
> 2 86 350
> 3 34 452
> 3 98 768
> 3 56 665
> 3 39 445
> 4 34 678
> 5 65 123
> 5 17 435
> 5 78 198
> 6 23 234
> 6 44 760
> 
> B =
> 1 23 345
> 1 45 636
> 0 00 000
> 2 26 985
> 2 86 350
> 3 34 452
> 3 98 768
> 3 56 665
> 0 00 000
> 4 34 678
> 5 65 123
> 5 17 435
> 5 78 198
> 6 23 234
> 6 44 760
> 
> If anyone knows how to do this, Help is greatly appreciated
> -Charlie

% A hint:
doc ismember

% Look at the the 'rows' option of that function.

% Then take it from there.