Filter löschen
Filter löschen

Delete empty rows from Cell array

83 Ansichten (letzte 30 Tage)
lucksBi
lucksBi am 28 Feb. 2017
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]

Akzeptierte Antwort

Jan
Jan am 28 Feb. 2017
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 Kommentare
lucksBi
lucksBi am 28 Feb. 2017
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?
Kristoffer Walker
Kristoffer Walker am 1 Jul. 2019
Thank you, Jan.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by