extract submatrix from a large matrix using loop

1 visualizzazione (ultimi 30 giorni)
Dear friends, I have a matrix 1140 by 330. I have to split the matrix into 60 matrices with the size of 19*330 using a for loop. does any one know how to do that?

Risposta accettata

Matt J
Matt J il 18 Lug 2016
You can use MAT2TILES ( Download ). For example,
A=rand(1140,330);
C=mat2tiles(A,[19,330]);
  2 Commenti
Sophi gra
Sophi gra il 18 Lug 2016
Modificato: Sophi gra il 18 Lug 2016
if i want to calculate the correlation coefficient, does it calculate it seperately? I use corrcoef(C), and I got error!
Matt J
Matt J il 18 Lug 2016
Yes, you can do
cellfun(@corrcoef,C,...)

Accedi per commentare.

Più risposte (2)

Andrei Bobrov
Andrei Bobrov il 18 Lug 2016
A=rand(1140,330);
out = permute(reshape(A',size(A,2),60,[]),[2,1,3]);

Guillaume
Guillaume il 18 Lug 2016
m = rand(1140, 330); %demo matrix
splitm = mat2cell(m, ones(1, 60) * 19, 330)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by