Bird
0
0

Find the error in this MATLAB code:

medium📝 Debug Q7 of 15
MATLAB - Cell Arrays and Structures
Find the error in this MATLAB code:
data = {42, 'hello', [1 2 3]; 'world'};
AMissing closing brace
BCannot mix strings and numbers in cell arrays
CCell array rows must have equal columns
DSemicolon inside cell array is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Analyze cell array structure

    Cell arrays can be multi-row, but each row must have the same number of columns.
  2. Step 2: Check given code

    First row has 3 elements, second row has 1 element, causing dimension mismatch error.
  3. Final Answer:

    Cell array rows must have equal columns -> Option C
  4. Quick Check:

    Cell array rows must align in size [OK]
Quick Trick: Cell array rows need equal columns [OK]
Common Mistakes:
  • Thinking mixed types are not allowed
  • Ignoring row size mismatch
  • Assuming semicolon is invalid inside cell arrays

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes