extract submatrix from a large matrix using loop

조회 수: 1 (최근 30일)
Sophi gra
Sophi gra 2016년 7월 18일
댓글: Matt J 2016년 7월 18일
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?

채택된 답변

Matt J
Matt J 2016년 7월 18일
You can use MAT2TILES ( Download ). For example,
A=rand(1140,330);
C=mat2tiles(A,[19,330]);
  댓글 수: 2
Sophi gra
Sophi gra 2016년 7월 18일
편집: Sophi gra 2016년 7월 18일
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 2016년 7월 18일
Yes, you can do
cellfun(@corrcoef,C,...)

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

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

Guillaume
Guillaume 2016년 7월 18일
m = rand(1140, 330); %demo matrix
splitm = mat2cell(m, ones(1, 60) * 19, 330)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by