Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to multiply two numbers and store the result.
MATLAB
result = 5 [1] 3;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * results in addition, not multiplication.
✗ Incorrect
The * operator multiplies two numbers in MATLAB.
2fill in blank
mediumComplete the code to subtract 4 from 10.
MATLAB
difference = 10 [1] 4;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + adds numbers instead of subtracting.
✗ Incorrect
The - operator subtracts the right number from the left.
3fill in blank
hardFix the error in the code to divide 20 by 5.
MATLAB
quotient = 20 [1] 5;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using * multiplies instead of dividing.
✗ Incorrect
The / operator divides the left number by the right number in MATLAB.
4fill in blank
hardFill both blanks to create a vector with elements from 1 to 10, stepping by 2.
MATLAB
vec = [1]:[2]:10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 as step skips numbers incorrectly.
✗ Incorrect
The colon operator start:step:end creates a vector from start to end with the given step size.
5fill in blank
hardFill all three blanks to create a structure with fields 'name', 'age', and 'score'.
MATLAB
student = struct('[1]', 'Alice', '[2]', 20, '[3]', 95);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'grade' instead of 'score' changes the field name.
✗ Incorrect
The struct function creates a structure with named fields. The field names must be strings.