Bird
0
0

Which MATLAB command correctly finds the starting indices of the substring 'fox' in the string variable sentence?

easy📝 Syntax Q3 of 15
MATLAB - String Handling
Which MATLAB command correctly finds the starting indices of the substring 'fox' in the string variable sentence?
Astrfind(sentence, 'fox')
Bcontains(sentence, 'fox')
Cfind(sentence == 'fox')
Dindex(sentence, 'fox')
Step-by-Step Solution
Solution:
  1. Step 1: Identify function for indices

    strfind returns starting indices of substring occurrences.
  2. Step 2: Eliminate incorrect options

    contains returns logical, not indices; find and index are invalid here.
  3. Final Answer:

    strfind(sentence, 'fox') -> Option A
  4. Quick Check:

    Indices needed, only strfind returns them [OK]
Quick Trick: Use strfind to get substring start indices [OK]
Common Mistakes:
  • Using contains expecting indices
  • Using find on strings incorrectly
  • Assuming index function exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes