Index Non-Empty Cells in Cell Array
408 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
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!
JF
0 commentaires
Réponse acceptée
Honglei Chen
le 28 Juin 2012
Modifié(e) : Honglei Chen
le 28 Juin 2012
x = {1,[],[],[]};
find(~cellfun(@isempty,x))
6 commentaires
Md. Mubarak Hossain
le 16 Mai 2017
a={1 [] [];2 [] 4;5 6 []} find(~cellfun(@isempty,a)) ans =
1
2
3
6
8
Here I'm getting answer in column wise. But How to get row wise answer.
That's means I wanna get
ans=1 4 6 7 8 .
How to get it?
Serge Kogan
le 21 Oct 2020
Md. Mubarak Hossain, You can get it by transposing the cell array a :
a={1 [] [];2 [] 4;5 6 []};
find(~cellfun(@isempty,a'))
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!