Bird
0
0

Which of the following is the correct way to create a character array in MATLAB?

easy📝 Syntax Q12 of 15
MATLAB - String Handling
Which of the following is the correct way to create a character array in MATLAB?
A<code>charArray = "abc";</code>
B<code>charArray = ["a", "b", "c"];</code>
C<code>charArray = { 'a', 'b', 'c' };</code>
D<code>charArray = 'abc';</code>
Step-by-Step Solution
Solution:
  1. Step 1: Recognize character array syntax

    Character arrays are created using single quotes around text, like 'abc'.
  2. Step 2: Differentiate from string and cell array

    Double quotes create string arrays, and curly braces create cell arrays, so only single quotes create character arrays.
  3. Final Answer:

    charArray = 'abc'; -> Option D
  4. Quick Check:

    Character arrays use single quotes = C [OK]
Quick Trick: Use single quotes for character arrays, double for strings [OK]
Common Mistakes:
  • Using double quotes for character arrays
  • Using curly braces which create cell arrays
  • Using square brackets with commas incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes