MATLAB: How to extract submatrix from the Main matrix??

MATLABmatrixsub matrix

HI everyone!!
I have a matrix 'Z' with values of '1' and '0'. Mat file is attached.
Now i'd like to extract sub matrices from 'Z' which consists of '1' with their corresponding index values .
example:
Z=size(15,10).
From'Z', i should get output like these three matrices in a loop.
a=Z(3:6,2:6);
b=Z(7:9,6:7);
c=Z(8:15,2);
thanks in advance!

Best Answer

If you have the image processing toolbox:
subnatrices = struct2cell(regionprops(logical(Z), 'Image'))