How can I see if one cell also exists in another cell array?
5 ビュー (過去 30 日間)
古いコメントを表示
Hello Matlab Community,
I have one 640x1 cell array (some cells are empty) and one 1280x1 cell array. Now, I would like to know how many of the words in the 640x1 cell array also appear in the 1280x1 cell array. Inside the cells are words ordered from Z-A. I have already played around with "==", "isequal" and "strcmp", but could not find a solution that works. In Excel I have solved it with "=SUMPRODUCT(COUNTIF(A2:A?;B2:B?). This always required to select the relevant filled cells and I would like to move the whole analysis over to MATLAB.
Is there a script that can do that, or do I have to stick to Excel? Is would be superb if that script would also ignore empty cells, so I do not have to select the cell array each time.
All the best, Luca
0 件のコメント
回答 (2 件)
KSSV
2016 年 9 月 19 日
You can remove the empty cells using :
A = A(~cellfun('isempty',A)) ; whre A is your cell array
Two compare the two cell arrays you can use functions like setdiff, intersect in MATLAB.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!