Remove empty rows from cell array

조회 수: 4 (최근 30일)
Cside
Cside 2020년 10월 3일
댓글: Cside 2020년 10월 3일
Hi, I have a cell array (attached) and would need to remove the rows with "" as they are empty fields, but still keep the rows with a 0. Is there a way I can do that and convert this cell array to a matrix? Currently, there is an error with i use cell2mat(A) as the fields are not the same data type.
Thank you! Appreciate any help
  댓글 수: 2
KSSV
KSSV 2020년 10월 3일
Check the data properly.....all cells are not numbers..one cell has a structure.
iwant = cell2mat(A(1:65))
The above gives column matrix.
Cside
Cside 2020년 10월 3일
편집: Cside 2020년 10월 3일
Hi, how could i clean that up to return a 359 x1 column matrix? and thereafter remove the missing rows? thanks!

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

채택된 답변

Mario Malic
Mario Malic 2020년 10월 3일
To replace string fields
idx = cellfun(@isstring, A);
A(idx) = {0};
After this, you can use
A = cell2mat(A)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by