MATLAB: Split 7000×4000 matrix in 10×10 matrices

MATLAB: Split 7000×4000 matrix in 10×10 matrices

matrix manipulationrandom

Hi,
I have a 7000×4000 Matrix of topographic data that I need to split into 10×10 matrices (Split by going every 10 rows and 10 columns). Any recommendations on how to go about it? Also once the matrix is split into the 10×10 matrices, I need it to randomly select 1 number out of the 100 in each matrices?
Regards, Akshay

Best Answer

  • A=randi(100,7000,4000) % Example
    B=mat2cell(A,10*ones(700,1),10*ones(400,1))
    C=cellfun(@(x) x(randi(100)),B)
    If you have Image Processing toolbox you can use blockproc function
    C1=blockproc(A,[10 10],@(x) x.data(randi(100)))
  • Add a Comment

    Your email address will not be published. Required fields are marked *