How can I see if one cell also exists in another cell array?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
KSSV
el 19 de Sept. de 2016
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 comentarios
Ver también
Categorías
Más información sobre Operators and Elementary Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!