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?
strA = '123';
strB = '456';
combined = strcat(strA, '-', strB);
disp(combined);
AError: Invalid input
B123456
C123-456
D123 - 456
Step-by-Step Solution
Solution:
  1. Step 1: Understand strcat with multiple inputs

    strcat concatenates all inputs without adding extra spaces.
  2. Step 2: Concatenate '123', '-', and '456'

    Result is '123-456' exactly as inputs joined.
  3. Final Answer:

    123-456 -> Option C
  4. Quick Check:

    strcat with '-' joins strings directly [OK]
Quick Trick: strcat joins all inputs directly without spaces [OK]
Common Mistakes:
  • Expecting spaces added automatically
  • Using + operator
  • Confusing strcat with sprintf

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes