Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a 1x3 cell array named C.
MATLAB
C = [1](1,3);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'array' or 'matrix' instead of 'cell' to create cell arrays.
Trying to create cell arrays with square brackets.
✗ Incorrect
The function 'cell' creates a cell array of specified size in MATLAB.
2fill in blank
mediumComplete the code to assign the string 'hello' to the first cell of cell array C.
MATLAB
C[1] = 'hello';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or square brackets instead of curly braces for cell content assignment.
Using multiple indices when only one is needed for a 1D cell array.
✗ Incorrect
Use curly braces { } to access or assign contents of a cell in MATLAB.
3fill in blank
hardFix the error in the code to create a 2x2 cell array with numbers 1 to 4 inside.
MATLAB
C = [1](2,2); C[2] = 1; C[3] = 2; C[4] = 3; C[5] = 4;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces for cell content assignment.
Using single index for 2D cell array assignment.
✗ Incorrect
Use 'cell' to create the array. Use curly braces with row and column indices to assign values inside cells.
4fill in blank
hardFill both blanks to create a cell array with mixed types: a string and a numeric array.
MATLAB
C = [1](1,2); C[2] = 'text';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces for assignment.
Using wrong indices for the cell assignment.
✗ Incorrect
Use 'cell(1,2)' to create the cell array. Assign the string to the first cell using curly braces with indices.
5fill in blank
hardFill all three blanks to create a 2x2 cell array and assign a string, a number, and a vector to different cells.
MATLAB
C = [1](2,2); C[2] = 'hello'; C[3] = 42; C{2,2} = [1, 2, 3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces for assignment.
Mixing up the indices for cell assignment.
✗ Incorrect
Create the cell array with 'cell(2,2)'. Assign 'hello' to C{1,1} and 42 to C{2,1}. The vector is assigned to C{2,2}.