Find function for cell array

1 回表示 (過去 30 日間)
Anupam  Saikia
Anupam Saikia 2019 年 5 月 7 日
コメント済み: Anupam Saikia 2019 年 5 月 16 日
I havr a cell myCell 1x200 Each cell contains set of three values like myCell{1,1} = 1,118,180 ... myCell{1,8}= 1,122,185 and so on If I have to use find function by providing all three values, how should I use?

採用された回答

Jan
Jan 2019 年 5 月 7 日
編集済み: Jan 2019 年 5 月 7 日
Do all elemts of the cell have the same size and type? Then working with a numerical array is easier and faster:
M = cat(1, myCell{:});
match = find(ismember(M, [1,2,128], 'rows'))
% or
find(M == [1,2,128]) % auto-expanding, >=Matlab R2016b
  1 件のコメント
Anupam  Saikia
Anupam Saikia 2019 年 5 月 16 日
Thank you so much.

サインインしてコメントする。

その他の回答 (1 件)

Adam
Adam 2019 年 5 月 7 日
wantedArray = [1,122,185];
cellfun( @(x) isequal(x,wantedArray), myCell );
You would be better off using a numeric array though for neatly structured data.
  1 件のコメント
Anupam  Saikia
Anupam Saikia 2019 年 5 月 16 日
Thank you so much.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by