Convert Cell to Matrix

조회 수: 8 (최근 30일)
ha ha
ha ha 2019년 6월 26일
답변: madhan ravi 2019년 6월 26일
Let' say, I have cell_A: 5x1 cell
cell_A={ [] ; [1] ; [5]; [] ; [2]};
How can I convert it to be matrix? 5-by-1 matrix
result_matrix=[ []; 1; 5 ; [] ; 2 ];

채택된 답변

madhan ravi
madhan ravi 2019년 6월 26일
As sir Walter mentioned already , you cannot have holes in matrices . So you could replace them with nans perhaps:
cell_A(cellfun('isempty',cell_A)) = {NaN};
Matrix = cell2mat(cell_A)

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 6월 26일
You cannot. Matrices cannot have "holes" in them.

카테고리

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

태그

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

Community Treasure Hunt

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

Start Hunting!

Translated by