Home > atmlab > handy > unique2.m

unique2

PURPOSE ^

unique2 Return rows from matrix2 not occuring in matrix1

SYNOPSIS ^

function rows = unique2(M1, M2)

DESCRIPTION ^

 unique2 Return rows from matrix2 not occuring in matrix1

 Given two matrices M1 and M2, returns a logical of those rows in M2 that
 do not occur in M1. A use case may be to concatenate subsequent granules,
 but not concatenating those rows in the second granule that already exist
 in the first one (like with AMSU/HIRS/MHS data).

 FORMAT

   rows = unique2(M1, M2)

 IN

   M1      matrix      primary matrix (left untouched)
   M2      matrix      secondary matrix (shall be reduced)

 OUT

   rows    logical     rows in M2 not occuring in M1

 $Id: unique2.m 6543 2010-10-07 15:57:41Z gerrit $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

unique2.m

SOURCE CODE ^

0001 function rows = unique2(M1, M2)
0002 
0003 % unique2 Return rows from matrix2 not occuring in matrix1
0004 %
0005 % Given two matrices M1 and M2, returns a logical of those rows in M2 that
0006 % do not occur in M1. A use case may be to concatenate subsequent granules,
0007 % but not concatenating those rows in the second granule that already exist
0008 % in the first one (like with AMSU/HIRS/MHS data).
0009 %
0010 % FORMAT
0011 %
0012 %   rows = unique2(M1, M2)
0013 %
0014 % IN
0015 %
0016 %   M1      matrix      primary matrix (left untouched)
0017 %   M2      matrix      secondary matrix (shall be reduced)
0018 %
0019 % OUT
0020 %
0021 %   rows    logical     rows in M2 not occuring in M1
0022 %
0023 % $Id: unique2.m 6543 2010-10-07 15:57:41Z gerrit $
0024 
0025 [~, I] = unique([M1; M2], 'rows', 'first');
0026 rows = false(size(M2, 1), 1);
0027 n1 = size(M1, 1);
0028 
0029 rows(I(I>n1)-n1) = true;

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005