Index Non-Empty Cells in Cell Array
295 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Honglei Chen
2012 年 6 月 28 日
編集済み: Honglei Chen
2012 年 6 月 28 日
x = {1,[],[],[]};
find(~cellfun(@isempty,x))
6 件のコメント
Md. Mubarak Hossain
2017 年 5 月 16 日
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
2020 年 10 月 21 日
Md. Mubarak Hossain, You can get it by transposing the cell array a :
a={1 [] [];2 [] 4;5 6 []};
find(~cellfun(@isempty,a'))
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!