0
0
MATLABdata~5 mins

String comparison in MATLAB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What function in MATLAB is used to compare two strings for equality?
The function strcmp is used to compare two strings for exact equality in MATLAB. It returns true if the strings are the same, otherwise false.
Click to reveal answer
beginner
How does strcmpi differ from strcmp in MATLAB?
strcmpi compares two strings ignoring case differences, while strcmp is case-sensitive.
Click to reveal answer
intermediate
What does the MATLAB function strncmp do?
strncmp compares the first N characters of two strings and returns true if they match exactly.
Click to reveal answer
intermediate
How can you compare two strings lexicographically in MATLAB?
Use the function strcmp for equality, or strcmpi for case-insensitive equality. For lexicographic order, use sort or relational operators on strings (MATLAB supports <, > for strings).
Click to reveal answer
beginner
What will strcmp('Hello', 'hello') return in MATLAB?
It will return false because strcmp is case-sensitive and 'H' is not equal to 'h'.
Click to reveal answer
Which MATLAB function compares two strings ignoring case?
Astrfind
Bstrcmp
Cstrcmpi
Dstrncmp
What does strcmp('abc', 'ABC') return?
Atrue
Berror
C1
Dfalse
Which function compares only the first N characters of two strings?
Astrcmp
Bstrncmp
Cstrfind
Dstrcmpi
If you want to check if two strings are exactly the same including case, which function do you use?
Astrcmp
Bstrncmp
Cstrcmpi
Dstrcat
What will strcmp('MATLAB', 'matlab') return?
Afalse
Btrue
C1
Derror
Explain how to compare two strings in MATLAB considering case sensitivity and ignoring case.
Think about which function cares about uppercase and lowercase letters.
You got /3 concepts.
    Describe how to compare only part of two strings in MATLAB.
    Focus on comparing the start of strings.
    You got /3 concepts.