필터 지우기
필터 지우기

Delete empty rows from Cell array

조회 수: 83 (최근 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 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