Concatenating cell arrays with a different number of columns
조회 수: 8 (최근 30일)
이전 댓글 표시
채택된 답변
Guillaume
2019년 6월 13일
편집: Guillaume
2019년 6월 13일
maxcols = max(cellfun('size', NonC_tRNAs, 2)); %get the number of columns of the widest array
padded = cellfun(@(m) [m, zeros(size(m, 1), maxcols - size(m, 2))], NonC_tRNAs, 'UniformOutput', false); %pad each array
NonC_tRNAs_Reference = vertcat(padded{:})
댓글 수: 7
mmfjerstad
2020년 3월 16일
Sorry if this is a dumb question, but what is "m" in this instance?
padded = cellfun(@(m) [m, zeros(size(m, 1), maxcols - size(m, 2))], NonC_tRNAs, 'UniformOutput', false); %pad each array
Guillaume
2020년 3월 16일
" what is "m" in this instance?"
An arbitrary name for the input variable of the anonymous function called by cellfun. It will be in turn each element of the same array.
추가 답변 (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!