Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to display the text 'Hello, World!' in MATLAB.
MATLAB
disp([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use quotes around the text.
Using double quotes instead of single quotes.
✗ Incorrect
In MATLAB, text strings must be enclosed in single quotes to be displayed correctly using disp.
2fill in blank
mediumComplete the code to assign the number 10 to a variable named 'x'.
MATLAB
[1] = 10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number as a variable name.
Putting the value on the left side.
✗ Incorrect
The variable name 'x' is used to store the value 10.
3fill in blank
hardFix the error in the code to correctly display the value of variable 'x'.
MATLAB
disp([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name which prints the letter x instead of its value.
Including a semicolon inside disp which causes an error.
✗ Incorrect
To display the value of variable x, just use its name without quotes or semicolon inside disp.
4fill in blank
hardFill both blanks to create a variable 'y' that stores the sum of 5 and 3.
MATLAB
[1] = 5 [2] 3;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong operator like - or * instead of +.
Using a wrong variable name.
✗ Incorrect
Variable y stores the sum of 5 and 3 using the plus (+) operator.
5fill in blank
hardFill all three blanks to create a variable 'z' that stores the product of 4 and 7, then display it.
MATLAB
[1] = 4 [2] 7; disp([3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * for multiplication.
Trying to display the variable before assigning it.
✗ Incorrect
Variable z stores 4 times 7 using *, then disp shows its value.