필터 지우기
필터 지우기

merge multiply cell together

조회 수: 1 (최근 30일)
UTA
UTA 2013년 8월 30일
Hi guys: I have two cells as follow:
C1={[1:10], [2; 4; 6], []};
C2={[],[],[2;3];
These two cell has same length and opposite void and valid elements, I want to put the elements in one cell , let's say C3={[1:10], [2; 4; 6],2;3]} How can I do that? Thank you very much!

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 30일
편집: Azzi Abdelmalek 2013년 8월 30일
C3=horzcat(C1,C2);
C3(cellfun('isempty',C3))=[]
  댓글 수: 1
Jan
Jan 2013년 8월 30일
Equivalent, but perhaps slightly faster for huge cells:
index = cellfun('isempty', C1);
C3 = cat(2, C1(~index), C2(index));

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by