Recall & Review
beginner
What does using parentheses () do when indexing a cell array in MATLAB?
Parentheses () return a subset of the cell array as another cell array, preserving the cell structure.
Click to reveal answer
beginner
What does using curly braces {} do when indexing a cell array in MATLAB?
Curly braces {} extract the contents inside the cell, returning the actual data stored in that cell.
Click to reveal answer
beginner
Given a cell array C = {1, 'hello', [2 3]}, what is the result of C(2)?
C(2) returns a 1x1 cell array containing the string 'hello'.
Click to reveal answer
beginner
Given the same cell array C = {1, 'hello', [2 3]}, what is the result of C{2}?
C{2} returns the string 'hello' directly, not inside a cell.
Click to reveal answer
intermediate
Why would you use parentheses () instead of curly braces {} when indexing a cell array?
Use parentheses () when you want to keep the result as a cell array, for example, to pass a subset of cells to another function expecting cells.
Click to reveal answer
What type of output do you get when you use curly braces {} to index a cell array?
✗ Incorrect
Curly braces {} extract the actual contents inside the cell.
What does C(1:2) return if C is a cell array?
✗ Incorrect
Parentheses () return a subset of the cell array as a cell array.
If C = {10, 20, 30}, what does C{3} return?
✗ Incorrect
Curly braces {} return the content inside the cell, here the number 30.
Which indexing method would you use to get a cell array containing only the second cell of C?
✗ Incorrect
Parentheses () return a cell array subset, so C(2) returns a cell array with the second cell.
What happens if you try to assign a value to C{2} when C is a cell array?
✗ Incorrect
Using curly braces {} on the left side replaces the content inside that cell.
Explain the difference between using parentheses () and curly braces {} when indexing a cell array in MATLAB.
Think about whether you want the cell itself or what is inside it.
You got /4 concepts.
Describe a situation where you would prefer to use parentheses () over curly braces {} when working with cell arrays.
Consider when the output needs to remain a cell array.
You got /3 concepts.