Remove empty rows from cell array

2 次查看(过去 30 天)
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