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?
str = '123-456-789';
newStr = strrep(str, '-', '/');
disp(newStr);
A123-456-789
B123/456-789
C123/456/789
D123456789
Step-by-Step Solution
Solution:
  1. Step 1: Understand the replacement

    All '-' characters are replaced by '/' in the string.
  2. Step 2: Apply replacement

    '123-456-789' becomes '123/456/789'.
  3. Final Answer:

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

    Replaced dashes with slashes = '123/456/789' [OK]
Quick Trick: strrep replaces all instances of the target substring [OK]
Common Mistakes:
  • Replacing only one dash
  • Removing dashes instead of replacing
  • Syntax errors in strrep usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes