Delete empty rows from Cell array

83 次查看(过去 30 天)
Hi, I have this Cell array and i want to remove all the [] rows from all pages. I have tried almost everything related to this topic but nothing worked Thank you in advance for your help.
val(:,:,1) =
[44]
[33]
[]
[]
[]
[]
[]
[]
[]
[]
val(:,:,2) =
[44]
[33]
[]
[]
[]
[]
[]
[]
[]
[]
val(:,:,3) =
[]
[]
[11]
[44]
[33]
[]
[]
[]
[]
[]
val(:,:,4) =
[]
[]
[11]
[44]
[33]
[]
[]
[]
[]
[]
val(:,:,5) =
[]
[]
[11]
[44]
[33]
[]
[]
[]
[]
[]
val(:,:,6) =
[]
[]
[]
[]
[]
[44]
[22]
[]
[]
[]
val(:,:,7) =
[]
[]
[]
[]
[]
[44]
[22]
[]
[]
[]
val(:,:,8) =
[]
[]
[]
[]
[]
[]
[]
[11]
[22]
[33]
val(:,:,9) =
[]
[]
[]
[]
[]
[]
[]
[11]
[22]
[33]
val(:,:,10) =
[]
[]
[]
[]
[]
[]
[]
[11]
[22]
[33]

采纳的回答

Jan
Jan 2017-2-28
You have not tried "almost everything", but even "everything which works", in other words: This cannot work. A cell array must have the same number of elements for all rows and columns, as every other element. You cannot remove the empty elements from it and keep the positions of the non-empty elements at the same time. But you can get rid of the empty elements:
fullVal = val(~cellfun('isempty', val'));
But then val is not a 3D cell array anymore.
  2 个评论
lucksBi
lucksBi 2017-2-28
Thank you for your reply. but i have to compare values of non-zero indexes with another cell array. Is there any way to do this?

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by