0
0
MATLABdata~10 mins

First MATLAB program - Interactive Code Practice

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

Complete the code to display the text 'Hello, World!' in MATLAB.

MATLAB
disp([1]);
Drag options to blanks, or click blank then click option'
AHello, World!
BHello World
C'Hello, World!'
D"Hello, World!"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use quotes around the text.
Using double quotes instead of single quotes.
2fill in blank
medium

Complete 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'
A10
Bvalue
Cnum
Dx
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number as a variable name.
Putting the value on the left side.
3fill in blank
hard

Fix 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'
A'x'
Bx
Cx;
D"x"
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.
4fill in blank
hard

Fill 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'
Ay
B+
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong operator like - or * instead of +.
Using a wrong variable name.
5fill in blank
hard

Fill 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'
Az
B*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * for multiplication.
Trying to display the variable before assigning it.