how to combine two array of cells into one cellwise
조회 수: 5 (최근 30일)
이전 댓글 표시
I have two cell arrays with cells of different dimension and i want to combine them into one
as,
A={ [2,3 ; 2,7] [3,2 ;3,4 ;3,8] [4,3 ; 4,5] [5,4 ; 5,10] }
B={ [2,3,4 ; 2,3,8 ; 2,7,8 ; 2,7,12] [3,2,7 ; 3,4,5 ; 3,8,7] [4,3,2 ; 4,3,8 ; 4,5,10] [5,4,3] }
and I want answer to be like,
C={ [2,3,4,7,8,12] [2,3,4,5,7,8] [2,3,4,5,8,10] [3,4,5,10]
please help
댓글 수: 0
채택된 답변
the cyclist
2021년 11월 27일
A={ [2,3 ; 2,7] [3,2 ;3,4 ;3,8] [4,3 ; 4,5] [5,4 ; 5,10] };
B={ [2,3,4 ; 2,3,8 ; 2,7,8 ; 2,7,12] [3,2,7 ; 3,4,5 ; 3,8,7] [4,3,2 ; 4,3,8 ; 4,5,10] [5,4,3] };
C = cellfun(@(x,y)union(unique(x),unique(y)).',A,B,'UniformOutput',false);
C{:}
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!