Filter data of cell array
23 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I'm looking for a way to effectively filter data (in a cell array) similar to the filter option in Microsoft Excel. In the following I'll quickly describe a simple example with only 2 columns to clarify my problem:
The cell array consists of 2 columns and 4 rows where the to colums represent parameters and the rows different datasets. I now want to find the line number(s) of the row where column one is 1 and column 2 is A.
[1] [A]
[1] [B]
[0] [A]
[1] [A]
I can only think of using for loops for each column to solve this problem. However, in the real problem there are many more than 2 columns and I therefore seek to tackle the problem more efficiently. Do you have an idea how to start?
Thanks in advance,
bearli
0 件のコメント
採用された回答
Walter Roberson
2011 年 11 月 26 日
rows = find( arrayfun(@(RIDX) YourCell{RIDX,1} == 1 && strcmp(YourCell{RIDX,2}, 'A'), 1:size(YourCell,1)) );
If all of your values are numeric and all of your cells are scalar, then probably easier would be
t = cell2mat(YourCell);
rows = find( t(:,1) == 1 & t(:,2) == A );
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!