Bird
0
0

What will be the output of this MATLAB code?

medium📝 Predict Output Q5 of 15
MATLAB - String Handling
What will be the output of this MATLAB code?
s1 = "apple";
s2 = "Apple";
result = strcmpi(s1, s2);
disp(result);
A0
Bfalse
Cerror
D1
Step-by-Step Solution
Solution:
  1. Step 1: Understand strcmpi function

    strcmpi compares strings ignoring case differences.
  2. Step 2: Compare 'apple' and 'Apple'

    Ignoring case, both strings are equal, so strcmpi returns logical true (1).
  3. Final Answer:

    1 -> Option D
  4. Quick Check:

    Case-insensitive compare equal strings = 1 [OK]
Quick Trick: strcmpi returns 1 for equal strings ignoring case [OK]
Common Mistakes:
  • Expecting 0 for different case
  • Confusing output type (logical vs string)
  • Using strcmp instead of strcmpi

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes