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!