0% found this document useful (0 votes)
11 views17 pages

PracticeFinal_Fall2023

The document is the final exam for EML3035, Fall 2023, consisting of multiple-choice questions related to MATLAB. It includes instructions for filling out the exam and a variety of questions covering MATLAB concepts, coding, and syntax. The exam is structured into sections with varying point values for each question.

Uploaded by

hdwuef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views17 pages

PracticeFinal_Fall2023

The document is the final exam for EML3035, Fall 2023, consisting of multiple-choice questions related to MATLAB. It includes instructions for filling out the exam and a variety of questions covering MATLAB concepts, coding, and syntax. The exam is structured into sections with varying point values for each question.

Uploaded by

hdwuef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B.

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.

• I recommend reading every question carefully!


• 125 points total. All multiple choice questions.

Below: help plot

Below: ASCII table, where the ASCII character is on the right side of each column.

0 48 5 53 Space 32 a 97 f 102 k 107 p 112 u 117 z 122


1 49 6 54 b 98 g 103 l 108 q 113 v 118
2 50 7 55 c 99 h 104 m 109 r 114 w 119
3 51 8 56 d 100 i 105 n 110 s 115 x 120
4 52 9 57 e 101 j 106 o 111 t 116 y 121

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:

Questions 1-5 (1 pt each)

1) What does MATLAB stand for?

a) Modeling and Analysis Tool for Laboratory Work


b) Mathematics and Laboratory Toolbox
c) Manipulation and Transformation Language for Algorithmic Breakthroughs
d) Mathematical Laboratory Resource
e) Matrix Laboratory

2) What is the size of the matrix below?

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

4) Which of the following variable names is acceptable in MATLAB?

a) M4tlAb2023
b) m@thematics
c) science.
d) variable name
e) 4pplesauce

5) What is the value of the file identifier when fopen() fails?

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:

Questions 6-15 (2 pts each)

6) What is the final value of x in the code below?

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

8) What is the output of the line below?

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','--')

10) What is the purpose of preallocation?

a) To plot multiple graphs on the same figure


b) To solve a system of equations
c) To ensure matrix multiplication is possible
d) To save computation time
e) To convert cells back to characters

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?

a) Matrix multiplication, i.e., the linear algebra operation


b) Matrix transpose
c) Solving systems of equations
d) Structure creation
e) Preallocation

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

14) What is the final value of mass in the code below?

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:

Questions 16-35 (3 pts each)

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) The variable fid will be negative


b) The file myinfo.txt will be created in your Current Directory
c) The user will be prompted for data to insert into the file
d) MATLAB will report an error

18) What is the value of C found below?

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?

a) x = linspace(0, 3, 100) b) x = linspace(0, 100, 3)


y = x^2; y = x.^2;

c) for x = 0:0.1:3 d) x = linspace(0, 3, 100)


y = x^2; y = x.^2;
end

20) What is the output of the code below?

syllabus = {'grades';'hw';'quizzes'};
disp(syllabus(2,1))

a) {‘r’}
b) {‘hw’}
c) ‘hw’
d) {‘h’}
e) Error

21) Which matrix has the most elements?

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?

layers = ['temperature', 'pressure', 'time'];


data.experiment1.layers(2) = 10;

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:

25) What is the final value of t in the code below?

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

a) [x,y] = [7 2; 8 2]\[24; 30]


b) [x,y] = [7 2; 8 2]/[24; 30]
c) [x,y] = [24 30]\[7 2; 8 2]
d) [x,y] = [24 30]/[7 2; 8 2]
e) [x,y] = [7 8; 2 2]./[24; 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)

a) When r = 2 and h = 4, the volume is 50.265 ft3


b) When r = 4 and h = 2, the volume is 50.265 ft^3
c) When r = 2 and h = 4, the volume is 50.3 ft^3
d) When r = 2 and h = 4, the volume is 50.265 ft^3
e) Nothing would appear in the Command Window

30) What is the value of z below?

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

32) What is the purpose of formatSpec for fscanf?

a) To tell MATLAB what kind of file type to open


b) To tell MATLAB what format you want your plots
c) To prevent errors when creating structures
d) To tell MATLAB what type of data to read
e) To prevent errors when creating functions
11
EML3035 Final Exam: Fall 2023 Test Form A 12/2/2023 B. Freidkes

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

34) What is the value of nargin in the function call below?

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:

Questions 36-45 (4 pts each)

36) The matrix B is defined below.

4 1 3 4
𝑩 = [3 6 1 2]
3 2 1 0

What is the value of final after the code below is run?

final = B([1,2], [2,3]) + B([3,1], [2,3])

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

38) What shape is plotted if you run the code below?

plot([1 2 3], [2 3 2])


hold on
plot([1 3],[2 2])

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.

zeta = 5:5:25; %damping ratio


wn = [20 30 40 50 60]; %natural frequency [rad/s]
%................... %Line 3

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:

41) What is the final value of number in the code below?

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

a) A([4 1], [3 1])


b) A([4 3], [4 1])
c) A([4 2], [3 2])
d) A([4 1], [1 3])
e) A([1 4], [3 1])

43) What is the value of answer in the code below?

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:

Extra Credit (2 points each)

Please write complete sentences. No complete sentences = fewer extra points.

1) What advice do you have for students taking this course next semester?

2) What advice do you have for me in regard to improving this course?

17

You might also like