0
0
MATLABdata~10 mins

Arithmetic operators 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 add two numbers and store the result in sum.

MATLAB
a = 5;
b = 3;
sum = a [1] b;
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication * instead of addition.
Using division / instead of addition.
2fill in blank
medium

Complete the code to multiply two numbers and store the result in product.

MATLAB
x = 7;
y = 4;
product = x [1] y;
Drag options to blanks, or click blank then click option'
A/
B-
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition + instead of multiplication.
Using division / instead of multiplication.
3fill in blank
hard

Fix the error in the code to correctly divide num1 by num2.

MATLAB
num1 = 10;
num2 = 2;
result = num1 [1] num2;
Drag options to blanks, or click blank then click option'
A/
B*
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication * instead of division.
Using subtraction - instead of division.
4fill in blank
hard

Fill both blanks to calculate the remainder when a is divided by b.

MATLAB
a = 17;
b = 5;
remainder = mod([1], [2]);
Drag options to blanks, or click blank then click option'
Aa
Bb
C17
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using the numbers directly instead of variables.
Swapping the order of inputs.
5fill in blank
hard

Fill both blanks to create a vector of squares of numbers from 1 to 5.

MATLAB
numbers = 1:5;
squares = numbers [1] [2];
Drag options to blanks, or click blank then click option'
A.^
B2
C*
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using ^ instead of .^ which causes an error for vectors.
Using multiplication * instead of power operator.