フィルターのクリア

How do I get the indices of non-empty cells from a cellstr array?

15 ビュー (過去 30 日間)
Robert Moss
Robert Moss 2012 年 7 月 25 日
I am using regexp to determine which cells in a cellstr array contain the characters of interest. Regexp returns a cell array with [1] where there is a match, and [] where it does not match. What is the best way to get the indices of the [1] (matching) cells? The find function will not operate on cell arrays. Using cell2mat returns an array with all empty [] cells removed.
Obviously I could loop through the thing and figure it out the hard way, but I'm guessing there is a simpler "MATLAB Way" to do it.

採用された回答

Honglei Chen
Honglei Chen 2012 年 7 月 25 日
編集済み: Honglei Chen 2012 年 7 月 25 日
Here is an example
x = {1,[]}
find(~cellfun(@isempty,x))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by