what does strcmp does in matlab

strcmp function in Matlab is used to compare two strings and returns 1 if they are same, otherwise 0. Here's an example:

main.m
str1 = 'Hello';
str2 = 'hello';
result = strcmp(str1, str2);
disp(result); % Output will be "0" (false) since "Hello" and "hello" are not same due to case sensitivity.
168 chars
5 lines

It should be noted that strcmp is case sensitive. If you don't want the comparison to be case sensitive, you can use the strcmpi function instead.

related categories

gistlibby LogSnag