How can I delete a row from a cell aray, with empty cell as first column

4 次查看(过去 30 天)
I have a cell aray with 2 columns.
A={[7;8],6;[],19;[3;4;5;6],11;[],25;[4;5],58;[],63}
I want to delete all rows which contain empty cells.How can I do that?

采纳的回答

Ken Atwell
Ken Atwell 2014-3-25
编辑:Ken Atwell 2014-3-25
I think this is what you are after: The line of code below will call isempty on each row in the first column, and then trim A to only those rows that are not empty.
>> A(~cellfun(@isempty, A(:,1)), :)
ans =
[2x1 double] [ 6]
[4x1 double] [11]
[2x1 double] [58]

更多回答(1 个)

Andrei Bobrov
Andrei Bobrov 2014-3-25
A(~any(cellfun(@isempty, A),2), :)

类别

Help CenterFile Exchange 中查找有关 Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by