필터 지우기
필터 지우기

Concatenating cell arrays with a different number of columns

조회 수: 8 (최근 30일)
Sumara
Sumara 2019년 6월 13일
댓글: Guillaume 2020년 3월 16일
I have a 64x1 cell array that looks like this, I would like to vertically concatenate the cells in this array, and pad the rows with less columns with zeros blah.PNG

채택된 답변

Guillaume
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
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
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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by