other than strcmp???
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to use strcmp to compare 2 logical arrays, reading the notes, this cannot be used for logical arrays, only character arrays.
http://www.mathworks.com/help/techdoc/ref/strcmp.html
TF = strcmp(C1, C2)
As it stands i have 2 options, either:
1) find a function that will allow me to compare logical arrays.(No such look so far).
2) convert all the 1's to a specific letter and all my 0's to a different letter also, then i should be able to use strcmp. (But am unsure how to change specific data in an array.)
Regards
AZZA
0 commentaires
Réponses (3)
Paulo Silva
le 14 Mar 2011
a=logical([1 0 1 1])
b=logical([1 0 1 1])
isequal(a,b)
ans=
1
a=logical([1 0 1 1])
b=logical([1 0 0 1])
isequal(a,b)
ans=
0
0 commentaires
Walter Roberson
le 14 Mar 2011
You cannot successfully strcmp logical values for no particular reason I can see. The comparison just returns false.
You can, however,
strcmp(char(C1),char(C2))
0 commentaires
AZZA
le 14 Mar 2011
1 commentaire
Walter Roberson
le 14 Mar 2011
That approach will not work if A and B are not the same size, and it is unable to detect locations where one of the two has a 0 but the other has a 1.
Voir également
Catégories
En savoir plus sur Cell Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!