I have a very large 3D matrix, and I need to call some specific templates with a special configuration from this large matrix. For example, I need submatrices that their elements a, b, c, .., h are equal to a certain value (this is not a pattern match, but I need some patterns that have a specific value)
Is there a decision to find them very quickly? One solution, as I know, is to scan the matrix and save its template in the database, and then use the PCA to reduce the size of the database, but I'm looking for a more accurate method.
For example, suppose I have a matrix like I:
I=[1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0]
then I have another matrix as shown below:
p=[1 0 NaN NaN 1 NaN NaN NaN NaN]
then I have to look in "I" to find the rows, their columns 1,2 and 5 are 1,0,1 respectively (in this example, the row of 6 is the correct row. reality, the size of my matrix (I) is very large (more billion), and if I use a loop to find these strings, it takes a lot of time. I am looking for a quick code or method. I hope it will be meaningful now!