Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a row vector with elements 1 to 5.
MATLAB
v = [1 [1] 5];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a semicolon
; inside square brackets creates a column vector, not a row vector.Using a comma
, is valid but not the best way to create a sequence.✗ Incorrect
In MATLAB, the colon operator : creates a sequence of numbers. So 1:5 creates a row vector [1 2 3 4 5].
2fill in blank
mediumComplete the code to create a column vector with elements 1 to 5.
MATLAB
v = [1[1]5]';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a semicolon
; creates [1;5]' which is row [1 5].Using a comma
, creates [1,5]' which is column [1;5] but only two elements.✗ Incorrect
In MATLAB, the colon operator : creates the row vector [1 2 3 4 5]. Transposing it with ' creates the column vector [1;2;3;4;5].
3fill in blank
hardFix the error in the code to create a column vector with elements 1 to 3.
MATLAB
v = [1 [1] 3]';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a semicolon
; creates [1;3]' row [1 3].Using a comma
, creates [1,3]' column [1;3] only two elements.✗ Incorrect
In MATLAB, use colon : to create row vector [1 2 3], then transpose ' to get column vector [1;2;3].
4fill in blank
hardComplete the code to create a row vector with elements 2 to 8.
MATLAB
v = [[1] : 8];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolon
; creates a column vector, not a row vector.Using commas
, without the colon operator does not create a sequence.✗ Incorrect
In MATLAB, the colon operator : creates sequences.
5fill in blank
hardComplete the code to create a column vector with elements 5 to 15.
MATLAB
v = [[1]:15]';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas
, creates a row vector before transpose.Not using the colon operator fails to create the full sequence.
✗ Incorrect