필터 지우기
필터 지우기

how to divide matrix using mat2cell

조회 수: 1 (최근 30일)
Lucrezia Cester
Lucrezia Cester 2021년 2월 13일
댓글: Lucrezia Cester 2021년 2월 13일
Hello,
I have a 9 matrices of size 1x21996,
how can I divide the 9 matrices to be 6 of 1x3666 each?
I tried this but it only saves the last iteration
for a=1:numel(B)
A=mat2cell( B{a},[1],[3666 3666 3666 3666 3666 3666])
end
thanks.

채택된 답변

Jan
Jan 2021년 2월 13일
Are you sure you need a cell array? If the chunks have the same size a numerical array is much more efficient:
A = rand(1, 21996);
B = reshape(A, [], 6);
Now use B(:, k) to access the k.th subvector.
If you really need a cell:
C = num2cell(reshape(A, 6, []), 2);
  댓글 수: 1
Lucrezia Cester
Lucrezia Cester 2021년 2월 13일
thank you very much! yes this worked better

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by