Home > Mateda2.0 > otherfiles > reducemat.m

# reducemat

## PURPOSE

[NewMat] = reducemat(Mat,siz)

## SYNOPSIS

function[NewMat] = reducemat(Mat,siz)

## DESCRIPTION

     [NewMat] =  reducemat(Mat,siz)
     reducemat extracts the set of rows of a given matrix that satisfy that
     each pair of rows are different in at least siz elements. When siz is
     equal to the number of columns, reducemat gives the unique rows in the
     original matrix
     INPUTS:
     Mat: Original matrix
     OUTPUTS:
     Mat: Reduced matrix

     Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function[NewMat] =  reducemat(Mat,siz)
    0002 % [NewMat] =  reducemat(Mat,siz)
    0003 % reducemat extracts the set of rows of a given matrix that satisfy that
    0004 % each pair of rows are different in at least siz elements. When siz is
    0005 % equal to the number of columns, reducemat gives the unique rows in the
    0006 % original matrix
    0007 % INPUTS:
    0008 % Mat: Original matrix
    0009 % OUTPUTS:
    0010 % Mat: Reduced matrix
    0011 %
    0012 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0013 sizeNewMat = 1;
    0014 NewMat = Mat(1,:);
    0015
    0016
    0017 for i=2:size(Mat,1)
    0018  j = sizeNewMat;
    0019  while( j>=1 & (sum(Mat(i,1:siz) == NewMat(j,1:siz)) <siz))
    0020   j = j-1;
    0021  end
    0022
    0023  if(j==0)
    0024    sizeNewMat = sizeNewMat + 1;
    0025    NewMat = [NewMat;Mat(i,:)];
    0026  end
    0027
    0028 end