Delete empty rows from Cell array

104 ビュー (過去 30 日間)
lucksBi
lucksBi 2017 年 2 月 28 日
コメント済み: Kristoffer Walker 2019 年 7 月 1 日
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?
Kristoffer Walker
Kristoffer Walker 2019 年 7 月 1 日
Thank you, Jan.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by