how to remove [0,0,0] cell from an array

조회 수: 3 (최근 30일)
The Sanchi
The Sanchi 2021년 10월 16일
댓글: The Sanchi 2021년 10월 18일
I have a 8X1 column cell array with zeros as follows
[0,0,0]
4x3 double
5x3 double
10x3 double
6x3 doubel
[0,0,0]
4x3 double
8x3 double
Each cell has Nx3 data inside. [0,0,0] is 1x3 . I want to remove the cells that includes [0,0,0] and obtain
4x3 double
5x3 double
10x3 double
6x3 double
4x3 double
8x3 double
when I use
for i = 1:8
A{i}(A{i} == 0) = [],
end
it gives an error, "Brace indexing not supported for variables this type"
Thank you in advance !!!!

채택된 답변

DGM
DGM 2021년 10월 17일
Consider:
C = {rand(2,3) rand(3,3) rand(4,3) [0 0 0] rand(5,3)}.'
C = 5×1 cell array
{2×3 double} {3×3 double} {4×3 double} {[ 0 0 0]} {5×3 double}
iszerotuple = cell2mat(cellfun(@(x) isequal(x,[0 0 0]),C,'uniform',false))
iszerotuple = 5×1 logical array
0 0 0 1 0
C = C(~iszerotuple)
C = 4×1 cell array
{2×3 double} {3×3 double} {4×3 double} {5×3 double}
  댓글 수: 1
The Sanchi
The Sanchi 2021년 10월 18일
It worked !!!!!!. Thank you so much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by