MATLAB: Delete empty rows from Cell array

cell arraysdelete empty rows

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]

Best Answer

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.