0
0
MATLABdata~10 mins

Script files and editor 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 create a script file that assigns 10 to variable x.

MATLAB
x = [1];
Drag options to blanks, or click blank then click option'
A'10'
B10
Cx
Dten
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around numbers, which makes them strings.
Using variable names instead of values.
2fill in blank
medium

Complete the code to display the value of variable y in the script.

MATLAB
y = 5;
disp([1]);
Drag options to blanks, or click blank then click option'
A'y'
B5
Cdisp
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name in disp.
Passing a number directly instead of the variable.
3fill in blank
hard

Fix the error in the script to correctly calculate the square of z.

MATLAB
z = 4;
square = z[1]2;
Drag options to blanks, or click blank then click option'
A^
B**
Cx
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of ^ for exponentiation.
Using ** which is invalid in MATLAB.
4fill in blank
hard

Fill both blanks to create a script that calculates the area of a circle with radius r.

MATLAB
r = 3;
area = [1] * r[2] 2;
Drag options to blanks, or click blank then click option'
Api
B*
C^
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of ^ for squaring.
Using + instead of * for multiplication.
5fill in blank
hard

Fill all three blanks to create a script that calculates the average of three numbers a, b, and c.

MATLAB
a = 4;
b = 5;
c = 6;
avg = ([1] + [2] + [3]) / 3;
Drag options to blanks, or click blank then click option'
Aa
Bb
Cc
Davg
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable avg inside the sum.
Using numbers instead of variables inside the sum.