Comparing Strings
Create a script file and type the following code into it:
str1 = 'This is test'
str2 = 'This is text'
if (strcmp(str1, str2))
sprintf('%s and %s are equal', str1, str2)
else
sprintf('%s and %s are not equal', str1, str2)
end
When you run the file, it displays the following result:
str1 =
This is test
str2 =
This is text
ans =
This is test and This is text are not equal
No comments:
Post a Comment