Bird
0
0

What is the output of the following MATLAB code?

medium📝 Predict Output Q13 of 15
MATLAB - String Handling
What is the output of the following MATLAB code?
str = "MATLAB";
charArr = 'MATLAB';
disp(class(str));
disp(class(charArr));
Astring char
Bchar string
Cstring string
Dchar char
Step-by-Step Solution
Solution:
  1. Step 1: Identify variable types

    Variable str is created with double quotes, so it is a string type. Variable charArr uses single quotes, so it is a character array (char).
  2. Step 2: Understand class() output

    The class() function returns the type name as a string. So class(str) returns 'string' and class(charArr) returns 'char'.
  3. Final Answer:

    string char -> Option A
  4. Quick Check:

    Double quotes = string, single quotes = char [OK]
Quick Trick: class() shows 'string' for double quotes, 'char' for single quotes [OK]
Common Mistakes:
  • Assuming both are 'char' type
  • Confusing output order
  • Thinking class() returns variable content

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes