Comparing characters in a matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a (nx1) matrix,M, that stores a list of characters and I need to iterate through a loop and keep comparing the i-th character in the matrix with a temp character.
But I'm not sure how to do this, i tried using M{i,1}== tmp and strcmp(M{i,1},tmp) but neither seem to work. Please help, thank you so much!
5 commentaires
Réponse acceptée
Azzi Abdelmalek
le 25 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 25 Fév 2013
strcmp(M(i),tmp)
9 commentaires
Azzi Abdelmalek
le 25 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 25 Fév 2013
The problem is tmp is not equal to 'U' but to something like
'U ' % with spaces
Try this to remove space from tmp
strcmp(M(1),strtrim(tmp))
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Matrices and 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!