Font size
WorksheetsMATLAB Exam prep
Total questions: 25
Worksheet time: 18mins
What is the symbol for division?
\
/
%
^
x = 2;
if x > 2
y = 2*x;
elseif x < 2
y = 3*x;
else
y = 6*x;
end
What is y?
2
4
6
12
vec = [1 6 20 3 2];
[m, n] = max(vec);
What is the value of n?
5
20
3
2
What is the result of
mod(25,6)?
(a)
x = [1 0 0]; y = [0 1 0];
new = 3*sum(x|y)
What is the value of new?
(a)
for index = 1:2:10
v = index*3;
end
How many iterations of the loop will
this code perform?
3
5
6
12
sum([1; 5; 3; 3; 7])
5
7
19
5
x = [1 0 0 1 1]; y = [0 0 0 1 1];
x&y
How many zeros in the resulting
vector?
(a)
a = [2; 5; 3; 6; 4];
What is the result of a(3)?
(a)
function apples = countapples(people, hours)
How many return values from the above function?
0
1
2
3
fprintf('pi is %6.4f\n', pi)
How many digits will be displayed
after the decimal point?
(a)
mat = [2 1 3; 5 4 6; 7 8 9];
What is in mat(2,1)?
1
2
7
5
If you need to find the cosine of a 30 degree angle you use the code cos(30)
True
False
x = 2;
while x<7
x = x+3;
end
What is stored in x?
(a)
1+2/2*3+5
(a)
x = 1:0.5:3.5;
What is the result of length(x)?
3.5
6
7
100
mat = [1 2 3; 4 5 6];
In which row is the 4 located?
(a)
The workspace is where you type in MATLAB instructions
True
False
What is the default output format for MATLAB?
format bank
format long
format compact
format short
Choose the valid variable name
1Number
oneNum
_one_Number
one-num
Type in the MATLAB code for ln(50)
(a)
All vectors are arrays
True
False
You should use while loops when you know ahead of time how many times the code in the loop should run
True
False
Given a = [6 2 4 1]; and
b = 1×4 logical array
1 0 1 0. What is the result of a(b)?
[2 1]
this does not work
[6]
[6 4]
When a person types information in response to an input statement what is it stored as by default?
a number
a text string
whatever is appropriate
