compare cells discriminating the order and empty cells
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, how could I compare cell(1024x6) with another (same size), comparing row by row. Avoiding problems with empty cells and not finding differences because of the order of the components. ex:
(a, cell 1x4) '10FTHF5GLUtm' '10fthf5glu[m] '[] []
(b, cell 1x4) '10FTHF5GLUtm' '10fthf5glu[m] '[] []
ERROR: (because of the empty cells)
(a, cell 1x4) ' *10fthf5glu[m]'* '10FTHF5GLUtm' [] []
(b, cell 1x4) '10FTHF5GLUtm' ' *10fthf5glu[m]'*[] []
difference found because the order of the cells is different despite the content is the same** I want to compare, without finding differences in this case. I would like to find differences only when the content inside the cell is different, but not because of the position.
Is there any way to do this?
Thanks!!
0 Commenti
Risposte (1)
Stephen Jue
il 12 Mag 2017
Modificato: Stephen Jue
il 12 Mag 2017
Hi,
What you can do is filter out the empty cells from your arrays, then use the setdiff function to do a set difference between these two cell arrays. This ignores the order of the elements.
Note that this assumes that each cell array contains all unique elements. If this is not the case, you may need to use a different technique (e.g. sorting).
aFiltered = a(find(~cellfun(@isempty, a)));
bFiltered = b(find(~cellfun(@isempty, b)));
setdiff(aFiltered, bFiltered) % if this is empty, there is no difference.
0 Commenti
Vedere anche
Categorie
Scopri di più su String Parsing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!