image thumbnail

fpat: a fuzzy pattern detector

by

 

19 Oct 2004 (Updated )

the only pattern detector you will ever need

fpatdemo
% FPAT
% Schwarz, Shoelson & Amphlett
% CSSM / 2004

% let us create two objects
        objA=zeros(10,9);
        objA(4:6,6:8)=magic(3);

        objB={
              '....v....x....v....x....v' % row 1: col finder
              'a good BRETT'              % row 2
              'a bad BrrrRETt'            % row 3
              'a wide B R E T T'          % row 4
              'a shaky B RET  T'          % row 5
              'a noisy bbB rRxy EeTTtTt'  % row 6
              'a wrapped BR'              % row 7
              'ET                   '     % row 8
              'T'                         % row 9
        };

% ...and some search templates
        tmplA=magic(3);
        tmplX='BRETT';
        tmplY='B RE';
        tmplZ='B R E';

% search for patterns
        resA=fpat(tmplA,objA,'-s');
        resX=fpat(tmplX,objB);
        resY=fpat(tmplY,objB);
        resZ=fpat(tmplZ,objB,'-mrg');

% ...and show matches
        resX
        resY
        resZ
        rowZ=resZ.row
        colZ=resZ.col
        resA
        parX=resX.par
resX = 

      magic: 'FPAT'
        ver: '25-Oct-2004 20:21:42'
       time: '25-Oct-2004 20:50:11'
    runtime: 0.047
        par: [1x1 struct]
       mode: 'ALL patterns'
       npat: 5
    isexact: [1 0 0 0 0]
    ismatch: [1 0 0 0 0]
     iswrap: [0 0 0 0 1]
     isolap: [0 0 0 0 0]
     patlen: [5 9 8 11 24]
     rowbeg: [2 4 5 6 7]
     rowend: [2 4 5 6 9]
     colbeg: [8 8 9 11 11]
     colend: [12 16 16 21 1]
    matches: {5x1 cell}


resY = 

      magic: 'FPAT'
        ver: '25-Oct-2004 20:21:42'
       time: '25-Oct-2004 20:50:11'
    runtime: 0
        par: [1x1 struct]
       mode: 'ALL patterns'
       npat: 1
    isexact: 1
    ismatch: 1
     iswrap: 0
     isolap: 0
     patlen: 4
     rowbeg: 5
     rowend: 5
     colbeg: 9
     colend: 12
    matches: {'B RE'}


resZ = 

      magic: 'FPAT'
        ver: '25-Oct-2004 20:21:42'
       time: '25-Oct-2004 20:50:11'
    runtime: 0.016
        par: [1x1 struct]
       mode: 'ALL patterns'
       npat: 2
    isexact: [1 0]
    ismatch: [1 0]
     iswrap: [0 0]
     isolap: [0 0]
     patlen: [5 8]
        row: [2x2 uint32]
        col: [2x2 uint32]
    matches: {2x1 cell}


rowZ =

           4           6
           4           6


colZ =

           8          11
          12          18


resA = 

      magic: 'FPAT'
        ver: '25-Oct-2004 20:21:42'
       time: '25-Oct-2004 20:50:11'
    runtime: 0.047
        par: [1x1 struct]
       mode: 'ALL patterns'
       npat: 1
    isexact: 0
    ismatch: 0
     iswrap: 1
     isolap: 0
     patlen: 21
     rowbeg: 4
     rowend: 6
     colbeg: 6
     colend: 8
    matches: []


parX = 

         mos: '7.0.1.24704 (R14) Service Pack 1'
         rel: 14
    exactflg: 0
    matchflg: 0
    nolapflg: 0
      mrgflg: 0
       ixflg: 0
        sflg: 0
      iclass: @uint32
    template: 'BRETT'
      tclass: 'char'
        tlen: 5
        tnan: [1x1 char]
      oclass: 'cell'
       osize: [9 1]
      sclass: 'char'
       ssize: [1 141]

Contact us