how to compare the content of two strings in a cell in matlab?
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bharat
am 5 Jan. 2015
Bearbeitet: Stephen23
am 6 Jan. 2015
Hi everyone. I want to compare two strings in cells s1 and s2 . I tried strcmp(s1(1,1),s2(1,1)) and strcmp(s1{1,1},s2{1,1}) but it returns zero even when they have same string. can someone help me out!. Thanks.
0 Kommentare
Akzeptierte Antwort
Stephen23
am 5 Jan. 2015
Bearbeitet: Stephen23
am 6 Jan. 2015
The documentation for both of strcmp and strcmpi clearly states that they accept cell arrays of strings as the inputs:
>> A = {'my_string'};
>> B = {'my_string'};
>> strcmp(A,B)
ans =
1
It may be that your indexing is not working properly. Can you please give more details about the variables s1 and s2: their class, size and contents would be useful. Or perhaps you have nested cell arrays? In order to help you any further, we need to know about those variables!
This might be worth reading too:
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!