de Rigo, D. (2012). This file is part of Mastrave. Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Mastrave. If not, see . --------------------------------------------------------------------------- [ pos , lid ] = matfind( data , pattern_matrix , overlap ) Find a given inside . Returns the starting positions of each occurrence and the logical version of in which each element is replaced by a boolean indicating whether the element matches an occurrence of or not. If the flag is set to a true value, even overlapped occurrences of the are searched for and reported. Otherwise, overlapped matches are ignored. Input arguments: ::cellnumstring(,numstring):: matrix of numbers or of characters (numstring) or cell array of numstrings (pre-alpha: supported only numstrings) ::numstring,nonempty(,vector):: matrix of numbers or of characters to search for inside (pre-alpha: supported only vectors) ::binary:: flag indicating whether or not overlapped occurrences of are allowed Example of usage: M = ones( 5 , 8 ) * 10; M( [1 3 5 6 8:12 14:16 18:20 25:29 32 37] ) = 20; [ pos , lid ] = matfind( M , [10;20;20] , 1 ) ch_all = ' *'; ch_begin = ' >'; data = 'oooooofooo bar booooooazoooooo' patterns = { 'ooo' , 'oo' , 'o' , ' b' , 'b' , 'A' } for i =1:numel(patterns) pattern = patterns{ i }; fprintf( 1 , '\npattern : ''%s''\n', pattern ); [ pos , lid ] = matfind( data , pattern , 0 ); tmp = ones( size(lid) ); tmp(pos)=2; fprintf( 1 , '%s\n%s\n%s\n' , data, ch_all(lid+1), ch_begin(tmp) ); [ pos , lid ] = matfind( data , pattern , 1 ); tmp = ones( size(lid) ); tmp(pos)=2; fprintf( 1 , '%s\n%s\n%s\n' , data, ch_all(lid+1), ch_begin(tmp) ); end version: 0.3.5: the module "matfind" of the Mastrave modelling library. In: Semantic Array Programming with Mastrave - Introduction to Semantic Computational Modelling. http://mastrave.org/doc/mtv_m/matfind

This file is part of Mastrave. Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Mastrave. If not, see . --------------------------------------------------------------------------- [ pos , lid ] = matfind( data , pattern_matrix , overlap ) Find a given inside . Returns the starting positions of each occurrence and the logical version of in which each element is replaced by a boolean indicating whether the element matches an occurrence of or not. If the flag is set to a true value, even overlapped occurrences of the are searched for and reported. Otherwise, overlapped matches are ignored. Input arguments: ::cellnumstring(,numstring):: matrix of numbers or of characters (numstring) or cell array of numstrings (pre-alpha: supported only numstrings) ::numstring,nonempty(,vector):: matrix of numbers or of characters to search for inside (pre-alpha: supported only vectors) ::binary:: flag indicating whether or not overlapped occurrences of are allowed Example of usage: M = ones( 5 , 8 ) * 10; M( [1 3 5 6 8:12 14:16 18:20 25:29 32 37] ) = 20; [ pos , lid ] = matfind( M , [10;20;20] , 1 ) ch_all = ' *'; ch_begin = ' >'; data = 'oooooofooo bar booooooazoooooo' patterns = { 'ooo' , 'oo' , 'o' , ' b' , 'b' , 'A' } for i =1:numel(patterns) pattern = patterns{ i }; fprintf( 1 , '\npattern : ''%s''\n', pattern ); [ pos , lid ] = matfind( data , pattern , 0 ); tmp = ones( size(lid) ); tmp(pos)=2; fprintf( 1 , '%s\n%s\n%s\n' , data, ch_all(lid+1), ch_begin(tmp) ); [ pos , lid ] = matfind( data , pattern , 1 ); tmp = ones( size(lid) ); tmp(pos)=2; fprintf( 1 , '%s\n%s\n%s\n' , data, ch_all(lid+1), ch_begin(tmp) ); end version: 0.3.5: the module "matfind" of the Mastrave modelling library

 

Daniele de Rigo

 


Copyright and license notice of the function matfind

 

 

The file matfind.m is part of Mastrave.

Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Mastrave. If not, see http://www.gnu.org/licenses/.

---------------------------------------------------------------------------

[ pos , lid ] = matfind( data , pattern_matrix , overlap )

Find a given pattern_matrix inside data. Returns the starting positions pos of each occurrence and the logical version of data in which each data element is replaced by a boolean indicating whether the element matches an occurrence of pattern_matrix or not. If the overlap flag is set to a true value, even overlapped occurrences of the pattern_matrix are searched for and reported. Otherwise, overlapped matches are ignored.

Input arguments:

data ::cellnumstring(,numstring):: matrix of numbers or of characters (numstring) or cell array of numstrings (pre-alpha: supported only numstrings)

pattern_matrix ::numstring,nonempty(,vector):: matrix of numbers or of characters to search for inside data (pre-alpha: supported only vectors)

overlap ::binary:: flag indicating whether or not overlapped occurrences of pattern_matrix are allowed

Example of usage:

M = ones( 5 , 8 ) * 10; M( [1 3 5 6 8:12 14:16 18:20 25:29 32 37] ) = 20; [ pos , lid ] = matfind( M , [10;20;20] , 1 )

ch_all = ' *'; ch_begin = ' >';

data = 'oooooofooo bar booooooazoooooo'

patterns = { 'ooo' , 'oo' , 'o' , ' b' , 'b' , 'A' } for i =1:numel(patterns) pattern = patterns{ i }; fprintf( 1 , '\npattern : ''%s''\n', pattern ); [ pos , lid ] = matfind( data , pattern , 0 ); tmp = ones( size(lid) ); tmp(pos)=2; fprintf( 1 , '%s\n%s\n%s\n' , data, ch_all(lid+1), ch_begin(tmp) );

[ pos , lid ] = matfind( data , pattern , 1 ); tmp = ones( size(lid) ); tmp(pos)=2; fprintf( 1 , '%s\n%s\n%s\n' , data, ch_all(lid+1), ch_begin(tmp) ); end

version: 0.3.5

Function declaration

 

 

[ pos , lid ] = matfind( data           ,
                         pattern_matrix ,
                         overlap        )

Description

 

 

Find a given pattern_matrix inside data . Returns the starting positions pos of each occurrence and the logical version of data in which each data element is replaced by a boolean indicating whether the element matches an occurrence of pattern_matrix or not. If the overlap flag is set to a true value, even overlapped occurrences of the pattern_matrix are searched for and reported. Otherwise, overlapped matches are ignored.

Input arguments

 

 


 data             ::cellnumstring(,numstring)::
                  matrix of numbers or of characters (numstring)
                  or cell array of numstrings (pre-alpha: supported
                  only numstrings)

 pattern_matrix   ::numstring,nonempty(,vector)::
                  matrix of numbers or of characters to search for
                  inside  data  (pre-alpha: supported only vectors)

 overlap          ::binary::
                  flag indicating whether or not overlapped occurrences
                  of  pattern_matrix  are allowed


Example of usage

 

 




   M                = ones( 5 , 8 ) * 10;
   M( [1 3 5 6 8:12 14:16 18:20 25:29 32 37] ) = 20;
   [ pos , lid ]    = matfind( M , [10;20;20] , 1 )

   ch_all           = ' *';
   ch_begin         = ' >';

   data             = 'oooooofooo bar booooooazoooooo'

   patterns         = { 'ooo' , 'oo' , 'o' , ' b' , 'b' , 'A' }
   for i =1:numel(patterns)
      pattern       = patterns{ i };
      fprintf( 1 , '\npattern : ''%s''\n', pattern );
      [ pos , lid ] = matfind( data , pattern , 0 );
      tmp           = ones( size(lid) );  tmp(pos)=2;
      fprintf( 1 , '%s\n%s\n%s\n' , data, ch_all(lid+1), ch_begin(tmp) );

      [ pos , lid ] = matfind( data , pattern , 1 );
      tmp           = ones( size(lid) );  tmp(pos)=2;
      fprintf( 1 , '%s\n%s\n%s\n' , data, ch_all(lid+1), ch_begin(tmp) );
   end


version: 0.3.5

Support

 

 

The Mastrave modelling library is committed to provide reusable and general - but also robust and scalable - modules for research modellers dealing with computational science.  You can help the Mastrave project by providing feedbacks on unexpected behaviours of this module.  Despite all efforts, all of us - either developers or users - (should) know that errors are unavoidable.  However, the free software paradigm successfully highlights that scientific knowledge freedom also implies an impressive opportunity for collectively evolve the tools and ideas upon which our daily work is based.  Reporting a problem that you found using Mastrave may help the developer team to find a possible bug.  Please, be aware that Mastrave is entirely based on voluntary efforts: in order for your help to be as effective as possible, please read carefully the section on reporting problems.  Thank you for your collaboration.

Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Daniele de Rigo

This page is licensed under a Creative Commons Attribution-NoDerivs 3.0 Italy License.

This document is also part of the book:
de Rigo, D. (2012). Semantic Array Programming with Mastrave - Introduction to Semantic Computational Modelling. http://mastrave.org/doc/MTV-1.012-1


Valid XHTML 1.0 Transitional