wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MATLAB Exam prep

Total questions: 25

Worksheet time: 18mins

Name
Class
Date
1.

What is the symbol for division?

a)

\

b)

/

c)

%

d)

^

2.

x = 2;

if x > 2

y = 2*x;

elseif x < 2

y = 3*x;

else

y = 6*x;

end

What is y?

a)

2

b)

4

c)

6

d)

12

3.

vec = [1 6 20 3 2];

[m, n] = max(vec);

What is the value of n?

a)

5

b)

20

c)

3

d)

2

4.

What is the result of

mod(25,6)?

(a)  

5.

x = [1 0 0]; y = [0 1 0];

new = 3*sum(x|y)

What is the value of new?

(a)  

6.

for index = 1:2:10

v = index*3;

end

How many iterations of the loop will

this code perform?

a)

3

b)

5

c)

6

d)

12

7.

sum([1; 5; 3; 3; 7])

a)

5

b)

7

c)

19

d)

5

8.

x = [1 0 0 1 1]; y = [0 0 0 1 1];

x&y

How many zeros in the resulting

vector?

(a)  

9.

a = [2; 5; 3; 6; 4];

What is the result of a(3)?

(a)  

10.

function apples = countapples(people, hours)

How many return values from the above function?

a)

0

b)

1

c)

2

d)

3

11.

fprintf('pi is %6.4f\n', pi)

How many digits will be displayed

after the decimal point?

(a)  

12.

mat = [2 1 3; 5 4 6; 7 8 9];

What is in mat(2,1)?

a)

1

b)

2

c)

7

d)

5

13.

If you need to find the cosine of a 30 degree angle you use the code cos(30)

a)

True

b)

False

14.

x = 2;

while x<7

x = x+3;

end

What is stored in x?

(a)  

15.

1+2/2*3+5

(a)  

16.

x = 1:0.5:3.5;

What is the result of length(x)?

a)

3.5

b)

6

c)

7

d)

100

17.

mat = [1 2 3; 4 5 6];

In which row is the 4 located?

(a)  

18.

The workspace is where you type in MATLAB instructions

a)

True

b)

False

19.

What is the default output format for MATLAB?

a)

format bank

b)

format long

c)

format compact

d)

format short

20.

Choose the valid variable name

a)

1Number

b)

oneNum

c)

_one_Number

d)

one-num

21.

Type in the MATLAB code for ln(50)\ln\left(50\right)  

(a)  

22.

All vectors are arrays

a)

True

b)

False

23.

You should use while loops when you know ahead of time how many times the code in the loop should run

a)

True

b)

False

24.

Given a = [6 2 4 1]; and

b = 1×4 logical array

1 0 1 0. What is the result of a(b)?

a)

[2 1]

b)

this does not work

c)

[6]

d)

[6 4]

25.

When a person types information in response to an input statement what is it stored as by default?

a)

a number

b)

a text string

c)

whatever is appropriate