Sequences for a 3D matrix
    2 views (last 30 days)
  
       Show older comments
    
It is possible to find sequences over the 3rd dimension for each element in Matlab? Lets say I have these matrix 3x3x5
            1 1 0  
A(:,:,1) =  0 0 1   
            1 1 1   
            1 1 0  
A(:,:,2) =  0 0 1   
            1 0 1 
            0 0 0  
A(:,:,3) =  1 1 0   
            0 0 0 
            1 0 0  
A(:,:,4) =  1 0 1   
            1 1 1 
            1 1 1  
A(:,:,5) =  0 0 1   
            0 1 0 
Now I want to finde sequneces lets 1's two time in a row over the 3rd dimension, so I get the result:
            2 1 0  
result =    1 0 2   
            1 1 1 
Antway to do that?
0 Comments
Answers (2)
  Andrei Bobrov
      
      
 on 14 Jan 2019
        
      Edited: Andrei Bobrov
      
      
 on 14 Jan 2019
  
      k = reshape([1,1,0],1,1,[]);
result = sum(convn(A,k,'same')==2,3);
See Also
Categories
				Find more on Creating and Concatenating Matrices in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!