필터 지우기
필터 지우기

Extract and realign cells into new cell

조회 수: 1 (최근 30일)
Xh Du
Xh Du 2017년 7월 4일
답변: KSSV 2017년 7월 4일
Hi all,
I have a cell array 'cellA' which contains cell:
cellA =
{2x1 cell} {2x1 cell} {2x1 cell}
{2x1 cell} {2x1 cell} {2x1 cell}
cellA{1}
ans =
[12x2 double]
[30x2 double]
All arrays in cellA are same size. Now what I want is to extract each double array and put them in a new cell, so I will have 2 new cells:
cellB =
[12x6 double]
[12x6 double]
cellC =
[30x6 double]
[30x6 double]
I know I can probably write a for loop to do this, but is there a faster, vectorized way?
Thanks!

채택된 답변

KSSV
KSSV 2017년 7월 4일
A = cell(2,3) ;
for i = 1:2
for j = 1:3
A{i,j}{1,1} = rand(12,2) ;
A{i,j}{2,1} = rand(30,2) ;
end
end
B = [A{:}] ;
B1 = mat2cell(cell2mat(reshape(B(1,:),2,3)),[12 12]);
B2 = mat2cell(cell2mat(reshape(B(2,:),2,3)),[30 30]);

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by