Comparing characters in a matrix
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Azzi Abdelmalek
2013 年 2 月 25 日
編集済み: Azzi Abdelmalek
2013 年 2 月 25 日
strcmp(M(i),tmp)
9 件のコメント
Azzi Abdelmalek
2013 年 2 月 25 日
編集済み: Azzi Abdelmalek
2013 年 2 月 25 日
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))
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!