PracticeFinal_Fall2023
PracticeFinal_Fall2023
Freidkes
Name:
Instructions:
• Please write your full name on this first page and the last page where the extra credit is.
• On your Bubble Sheet, fill out the following information:
o Name
o Student ID
o Test Form Code (This is A for both sections).
o Signature
• The Test Form Code is extremely important. Your Test Form Code is A.
o You will get one point off if you don’t fill this in.
• No calculator allowed.
• No laptop/MATLAB allowed.
• Since there are text/strings/characters questions, note that the word “Error” will only be
an answer if the code produces an error.
Below: ASCII table, where the ASCII character is on the right side of each column.
1
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
Intentional blank page. Use for scratch work. Nothing here will be graded.
2
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
2 3
𝑨 = [1 5 ]
6 4
a) 1x6
b) 6x1
c) 3x2
d) 2x3
e) 4x2
3) Which of the following is most associated with the concept of true or false?
a) Transpose
b) Preallocation
c) for loops
d) Cells
e) Booleans
a) M4tlAb2023
b) m@thematics
c) science.
d) variable name
e) 4pplesauce
a) -2
b) -1
c) 0
d) 1
e) NaN
3
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
x = 2;
y = x+1;
x = y^2 + x;
y = x-1;
a) 10
b) 11
c) 12
d) 13
e) 15
7) What is the value of the variable kk at the end of the code below?
kk = 3;
while kk <= 4 && kk == 3
kk = kk+1;
end
a) 1
b) 3
c) 4
d) 5
e) Error
class('37')
a) double
b) string
c) char
d) cell
e) Error
4
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
9) Assuming that the vectors x and y are defined properly, which line of code below will create
a black, dashed line with circular markers?
a) plot(x,y,'b','Marker','o','LineStyle','--')
b) plot(x,y,'k','o','--')
c) plot(x,y,'Color',[1 0 0],'Marker','o','LineStyle','--')
d) plot(x,y,'ko--')
e) plot(x,y,'k','Marker','o','--')
11) Which answer choice should be inserted into Line 3 to ensure a final value of r equal to 20?
r = 3; % Line 1
r = r^2 + 0.1; % Line 2
% .............% Line 3
r = 2*r; % Line 4
a) r = floor(r)
b) r = ceil(r)
c) r = zeros(r)
d) r = r-0.2
e) r = r
12) Which of the choices below is an example of how the dot operator (i.e., the period . ) is
used in MATLAB?
5
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
13) What will show in the Command Window if the line of code below is ran?
word1 = "final";
word2 = "exam";
word1 ~= word2
a) 0
b) final exam
c) 1
d) Error
e) Nothing appears
mass = 1;
for ii = [0 1 3 4]
mass = mass+ii;
end
a) 7
b) 8
c) 9
d) 10
e) Error
15) What can you use to edit plot/figure properties without typing any code?
a) Property Inspector
b) Figure Property Manager
c) Plot Edit Window
d) Code-free Plot Window
e) Aesthetics Editor
6
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
16) What is the value of sum at the end of the code below?
A = [3 4; 5 6; -2 2];
sum = 0;
for i = 1:3
if sum > 5
sum = sum + A(i,2);
else
sum = sum + A(2,i);
end
end
disp(sum)
a) 9
b) 12
c) 13
d) 15
e) Error
17) The file myinfo.txt does not exist. What happens if the code below is run?
fid = fopen('myinfo.txt','w')
A = [1; 2; 3];
B = [4 1];
C = A*B
a) [4 1; 8 2; 12 3]
b) [24; 6]
c) [24 6]
d) [5 8; 4 2; 3 12]
e) Error
7
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
19) The command plot(x,y) was run to produce the graph below (ignore aesthetics like line
width, color, etc.). Which answer defines x and y properly to create the graph?
syllabus = {'grades';'hw';'quizzes'};
disp(syllabus(2,1))
a) {‘r’}
b) {‘hw’}
c) ‘hw’
d) {‘h’}
e) Error
a) A = linspace(0,2,100)
b) A = [0 2 100]
c) A = 0:2:100
d) A = zeros(2,100)
e) A = 2.*100
8
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
22) What is the value of A once the code below is executed? Note that the file question21.txt is
shown on the right. Assume that the letter m is the last entry into the file.
fid = fopen('question21.txt');
A = fscanf(fid, '%s');
fclose(fid);
a) final exam
b) finalexam
c) f
d) 102 105 110 97 108 32 101 120 97 109
e) final
23) What is the name of the lowest sublayer in the structure below?
a) pressure
b) layers
c) experiment1
d) r
e) e
24) Which equation below corresponds with the line of code provided?
y = exp(2*(x-1)/3)/x+4
1
𝑒 2(𝑥−1) 𝑒 2(𝑥−3)
a) 𝑦= +4 b) 𝑦= +4
3𝑥 𝑥
2(𝑥−1)
𝑒 3 𝑒 2(𝑥−1)/3
c) 𝑦= d) 𝑦= +4
𝑥+4 𝑥
9
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
t = 3;
while t > 2 || t == 1
t = t*2;
t = abs(t-5); %absolute value
if t == 2
break
end
end
a) 1
b) 2
c) 3
d) 6
e) Infinite loop
26) Given the system of equations below, what command would yield the unknown variables x
and y?
7𝑥 + 2𝑦 = 24
8𝑥 + 2𝑦 = 30
27) If a file closes successfully using fclose(), what is the output (assuming the fclose() command
is not suppressed)?
a) ‘closed’
b) -1
c) 0
d) 1
e) ‘success’
28) What kind of data type is imported when using the fgetl function?
a) Structures
b) Strings
c) Cells
d) Doubles
e) Characters
10
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
29) What will the Command Window show if the code below is run?
h = 4; %height [ft]
r = 2; %radius [ft]
V = pi*r^2*h; %cylinder volume [ft^3]
fprintf(1,'When r = %i and h = %i, the volume is %.3f ft^3',r,h,V)
x = 4;
y = '3';
z = x+y;
a) 241
b) 55
c) 43
d) 7
e) Error
31) What is the value of product at the end of the code below?
A = [1 2 3 4; 4 3 2 1; 1 4 3 3];
m = size(A);
product = m(1)*m(2)
a) 2
b) 4
c) 8
d) 12
e) Error
Name:
33) The file experiment.txt contains 20 numbers in a column. What is the size of the matrix
data if the code below is ran?
fid = fopen('experiment.txt');
data = fscanf(fid, '%f',[3 Inf]);
fclose(fid);
a) 3x6
b) 20 x 1
c) 3x7
d) 3x5
e) Error
x = 0:100;
[y, z] = calculate(x)
a) 1
b) 2
c) 99
d) 100
e) 101
35) Which line of code corresponds with the equation below? Assume this equation is valid for
any x value.
𝑒 𝑥 (4𝑥 − 𝑥 2𝑥 )
𝑓(𝑥) =
−3
a) f(x) = exp(x)*(4*x-x^(2*x))/(-3)
b) f = exp(x)*(4*x-x^(2x))/(-3)
c) f = exp(x)*(4*x-x^(2*x))/(-3)
d) f(x) = e^x*(4*x-x^(2*x))/(-3)
e) f = exp(x)*(4*x-x^2*x/-3)
12
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
4 1 3 4
𝑩 = [3 6 1 2]
3 2 1 0
a) [2 6; 8 2]
b) [8 2; 2 6]
c) [4 3; 4 7]
d) [3 4; 7 4]
e) Error
37) What is the final value of the matrix A in the code below?
A = [4 5 1 2];
for i = 1:3
if A(i) > A(i+1)
A(i+1) = A(i);
A(i) = A(i+1);
end
end
a) 4411
b) 4444
c) 4555
d) 5555
e) 1125
a) Square
b) Line
c) Rectangle
d) Circle
e) Triangle
13
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
39) A solution to an overdamped vibrating system depends on the damping ratio, 𝜁 (zeta), and
natural frequency, 𝜔𝑛 , of the system. The equation is given by:
𝑠 = −𝜁𝜔𝑛 + 𝜔𝑛 √𝜁 2 − 1
In the code below, there are 5 damping ratio values and 5 natural frequencies, where the first
element of each are a pair (5,20), the second element of each are a pair (10,30), etc.
Which line of code should be placed on Line 3 to calculate all values of s for the five pairs?
a) s = -zeta*wn + wn*sqrt(zeta^2-1)
b) s = -zeta.*wn + wn.*sqrt(zeta.^2-1)
c) s = -zeta*wn + wn.*sqrt(zeta.^2-1)
d) s = -zeta.*wn + wn*sqrt(zeta^2-1)
e) None of the above
40) What is the final value of count below?
count = 0;
for i = 1:1
for j = 1:2
for k = 1:3
count = count+1;
end
end
end
disp(count)
a) 3
b) 5
c) 6
d) 7
e) 8
14
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
number = 0;
for i = 1:2
x = i;
for jj = 1:x^2
number = number+1;
end
end
a) 4
b) 5
c) 6
d) 7
e) 9
42) What command should we type to extract the matrix B from the matrix A?
2 7 3
1 2 4 9 6
𝑨=[ ]; 𝑩=[ ]
11 8 0 3 2
6 6 9
family = ['dad','mommy','son','aunt'];
money = 1;
for i = 1:length(family)
info.(family(i)) = money+i;
end
answer = info.(family(1)) + info.(family(4))
a) 7
b) 9
c) 10
d) 11
e) 12
15
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
44) What is the value of B once the code below is executed? Note that the file question44.txt is
shown on the right. Assume that the 7 is the last entry in the file and the answer choices were
transposed for minimizing space on the exam.
fid = fopen('question47.txt','r');
B = fscanf(fid, '%c%f');
fclose(fid)
a) 77 97 7 32 7
b) 55 7 97 32 7 32 55
c) 55 97 32 55 32 55
d) 55 7 97 7 32 7
e) Empty
45) What number is displayed in the Command Window for the code below? Note that the right
code is a subfunction.
Main Subfunction
thing = 'r3plac3m3nt'; function [output1, output2] = f(word)
[count1, count2] = f(thing);
disp(count2) count1 = 0;
count2 = 0;
for ii = 1:length(word)
if word(ii) > 96
count1 = count1+1;
else
count2 = count2+1;
end
end
output1 = count1;
output2 = count2;
a) 0
b) 3
c) 8
d) 11
e) Error
16
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes
Name:
1) What advice do you have for students taking this course next semester?
17