Appending one cell array to non-zero cells of another
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a cell array FINAL_OUTPUT < 50x1 cell > and another one called indexing as shown in the attached file. How can I append the indexing column inside the non-empty cells of FINAL_OUTPUT? In the end, I would like to have FINAL_OUTPUT{1,1} having size 3x3 FINAL_OUTPUT{2,1} having size < 1x3 > etc...and the empty cells of FINAL_OUTPUT should remain empty.
댓글 수: 3
채택된 답변
Stephen23
2015년 7월 2일
편집: Stephen23
2015년 7월 2일
>> out = cellfun(@(F,I)[F,num2cell(I)], FINAL_OUTPUT(check_not_empty), indexing, 'UniformOutput',false);
>> out{1}
ans =
'A' [ 110] [1]
'B' [ 110] [2]
'C' [2.8422e-14] [3]
>> out{2}
ans =
'A' [56.5000] [1]
>> out{3}
ans =
'A' [55] [1]
'B' [55] [2]
'C' [55] [3]
And of course to allocate back into the original cell array, just use indexing:
FINAL_OUTPUT(check_not_empty) = out;
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Sequence Alignment에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!