0
0
MATLABdata~10 mins

Variable creation and assignment in MATLAB - Interactive Code Practice

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

Complete the code to assign the value 10 to the variable x.

MATLAB
x = [1];
Drag options to blanks, or click blank then click option'
A'10'
Bx
C10
Dten
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number 10 inside quotes, which makes it a string.
Using a variable name instead of a value.
2fill in blank
medium

Complete the code to assign the string 'hello' to the variable greeting.

MATLAB
greeting = [1];
Drag options to blanks, or click blank then click option'
Ahello
B'hello'
C"hello"
Dgreeting
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes instead of single quotes for strings.
Not using quotes at all.
3fill in blank
hard

Fix the error in the code to assign the value 5 to variable num.

MATLAB
num = [1];
Drag options to blanks, or click blank then click option'
A'5';
B5
Cnum;
D5;
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the semicolon at the end of the statement.
Putting the number inside quotes.
4fill in blank
hard

Fill both blanks to create a variable 'result' that stores the sum of 3 and 7.

MATLAB
result = [1] [2] 7;
Drag options to blanks, or click blank then click option'
A3
B+
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
Swapping the order of numbers and operators.
5fill in blank
hard

Fill all three blanks to create a variable 'area' that stores the product of length and width.

MATLAB
area = [1] [2] [3];
Drag options to blanks, or click blank then click option'
Alength
B*
Cwidth
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Mixing up variable names.