Bird
0
0

Which of the following is the correct syntax to find the starting indices of substring 'cat' in string str = 'concatenate' using strfind?

easy📝 Syntax Q12 of 15
MATLAB - String Handling
Which of the following is the correct syntax to find the starting indices of substring 'cat' in string str = 'concatenate' using strfind?
Acontains(str, 'cat')
Bstrfind('cat', str)
Cstrfind(str, 'cat')
Dstrfind(str, cat)
Step-by-Step Solution
Solution:
  1. Step 1: Recall strfind syntax

    The first argument is the main string, second is the substring to find.
  2. Step 2: Check each option

    strfind(str, 'cat') correctly uses strfind(str, 'cat'). strfind('cat', str) reverses arguments. contains(str, 'cat') uses contains, not strfind. strfind(str, cat) misses quotes around 'cat'.
  3. Final Answer:

    strfind(str, 'cat') -> Option C
  4. Quick Check:

    strfind(mainString, substring) = strfind(str, 'cat') [OK]
Quick Trick: First argument main string, second substring in strfind [OK]
Common Mistakes:
  • Swapping arguments in strfind
  • Forgetting quotes around substring
  • Using contains instead of strfind for indices

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes