Index Non-Empty Cells in Cell Array

621 Ansichten (letzte 30 Tage)
John F
John F am 28 Jun. 2012
Kommentiert: Serge Kogan am 21 Okt. 2020
I have the following cell array
TEST = [1] [] [] [] []
I want to get the index position of the non-empty cell. I know I can do this using a loop, but is there any single command (like "find") that will do this?
Thank you!

Akzeptierte Antwort

Honglei Chen
Honglei Chen am 28 Jun. 2012
Bearbeitet: Honglei Chen am 28 Jun. 2012
x = {1,[],[],[]};
  6 Kommentare
Serge Kogan
Serge Kogan am 21 Okt. 2020
Md. Mubarak Hossain, You can get it by transposing the cell array a :
a={1 [] [];2 [] 4;5 6 []};

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Attila am 16 Mai 2017
Dear Mubarak,
This will work : find(~cellfun(@isempty,a'));


Mehr zu Structures 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