0
0
MATLABdata~10 mins

Cell array indexing (curly vs parentheses) in MATLAB - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to access the content of the first cell in the cell array.

MATLAB
value = C[1];
Drag options to blanks, or click blank then click option'
A1
B(1)
C[1]
D{1}
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces returns a cell, not the content.
Using square brackets causes syntax errors.
2fill in blank
medium

Complete the code to extract a sub-cell array containing the first two cells.

MATLAB
subCells = C[1];
Drag options to blanks, or click blank then click option'
A1:2
B{1:2}
C(1:2)
D[1:2]
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces returns contents, not a cell array.
Using square brackets causes syntax errors.
3fill in blank
hard

Fix the error in the code to assign the content of the second cell to variable x.

MATLAB
x = C[1];
Drag options to blanks, or click blank then click option'
A{2}
B(2)
C[2]
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses returns a cell array, not the content.
Using square brackets causes syntax errors.
4fill in blank
hard

Fill both blanks to create a cell array with two cells and access the content of the first cell.

MATLAB
C = [1], [2];
value = C[3];
Drag options to blanks, or click blank then click option'
A'apple'
B'banana'
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces to access content.
Using numeric values without quotes to create string cells.
5fill in blank
hard

Fill all three blanks to create a cell array, extract a sub-cell array, and get the content of the second cell in the sub-array.

MATLAB
C = [1], [2], [3];
subC = C[4];
value = subC[5];
Drag options to blanks, or click blank then click option'
A'cat'
B'dog'
C'bird'
D(2:3)
E(1:2)
F{2}
G{1}
H{3}
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces instead of parentheses to get sub-cell array.
Using parentheses instead of curly braces to get content.