Recall & Review
beginner
What does the
contains function do in MATLAB?The
contains function checks if a string or array of strings contains a specified substring and returns a logical true or false.Click to reveal answer
beginner
How does
strfind differ from contains in MATLAB?strfind returns the starting indices of the substring within the string, while contains returns a logical value indicating presence or absence.Click to reveal answer
beginner
What is the output of
strfind('hello world', 'o')?It returns the indices where 'o' appears: [5 8].
Click to reveal answer
intermediate
Can
contains handle arrays of strings in MATLAB?Yes,
contains can check each element of a string array or cell array of character vectors and return a logical array.Click to reveal answer
beginner
What happens if
strfind does not find the substring?It returns an empty array
[] indicating no matches.Click to reveal answer
What does
contains('apple', 'p') return?✗ Incorrect
contains returns true if the substring is found anywhere in the string.What is the output of
strfind('banana', 'na')?✗ Incorrect
strfind returns the starting indices of each occurrence of 'na' in 'banana', which are positions 3 and 5.If
strfind does not find the substring, what does it return?✗ Incorrect
strfind returns an empty array [] when no match is found.Which function returns a logical array when searching multiple strings?
✗ Incorrect
contains returns a logical array indicating presence of the substring in each element.What is the difference between
contains and strfind?✗ Incorrect
contains returns true/false, while strfind returns the starting positions of the substring.Explain how to use
contains to check if a substring exists in multiple strings.Think about searching in a list of words.
You got /3 concepts.
Describe what
strfind returns and how it can be used to find substring positions.Imagine looking for where a word starts inside a sentence.
You got /3 concepts.