Converting a cell array containing more cell arrays with different sizes to one cell matrix

조회 수: 3 (최근 30일)
Hi all, how to converting cell array containing more cell array (have different sizes) to one cell matrix? For example:
C=
{1x1 cell}
{1x3 cell}
{1x2 cell}
The matrix size inside the cell array is different, thus I cannot use vertcat or horzcat function. I try to use catpad function, but it only concatenate the cell individually.
F = {{[0.04,0.2,0.56;0.31,0.67,0.22]},{...
[6+6j,7+3j,8-6j;6+8j,7-6j,3-3j],...
[5+6j,8+5j;6+8j,7-6j;5+6j,3-9j],...
[1-6j,1-5j;1-8j,1+6j;1-6j,1+9j]},{...
[16+6j,7+3j,8-6j;6+8j,7-6j,3-3j],...
[5+6j,8+5j;6+8j,7-6j;5+6j,3-9j]}}
dim = 2
for kk = 1:numel(F)
for ii = numel(F{kk}):-1:2
for oo = 1:ii-1
R1 = catpad(dim,F{kk}{:})
R2 = catpad(dim,F{ii}{:})
break
end
end
end
If I add another cell into the cell F, I get an error. How to do this?
Thank you in advance

채택된 답변

David Hill
David Hill 2022년 9월 7일
F = {{[0.04,0.2,0.56;0.31,0.67,0.22]},{...
[6+6j,7+3j,8-6j;6+8j,7-6j,3-3j],...
[5+6j,8+5j;6+8j,7-6j;5+6j,3-9j],...
[1-6j,1-5j;1-8j,1+6j;1-6j,1+9j]},{...
[16+6j,7+3j,8-6j;6+8j,7-6j,3-3j],...
[5+6j,8+5j;6+8j,7-6j;5+6j,3-9j]}};
G=[F{1},F{2},F{3}]
G = 1×6 cell array
{2×3 double} {2×3 double} {3×2 double} {3×2 double} {2×3 double} {3×2 double}
  댓글 수: 4

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by