How to merge two cell arrays?
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a Dataset as follows:
Dataset =
4×2 cell array
{1×3 double} {0×0 double}
{1×3 double} {1×67 double}
{1×3 double} {0×0 double}
{1×3 double} {0×0 double}
I want to merge Dataset{2,1} and Dataset{2,2} and resulting outcome will be
Dataset =
4×1 cell array
{1×3 double}
{1×70 double}
{1×3 double}
{1×3 double}
How can I do that?
Thanks in advance!
댓글 수: 0
채택된 답변
Dana
2020년 7월 14일
Couldn't you just do it in a loop?
DataMerge = cell(4,1);
for j = 1:4
DataMerge{j} = [Data{j,1},Data{j,2}]
end
Actually, if you know that only the second row of Data will ever have a non-empty matrix in column 2, you can just do
DataMerge = Data(:,1);
DataMerge{2} = [Data{2,1},Data{2,2}];
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!