Exam I - BME 201 - Spring 2011: Instructions and Questions - Prof. Gregory Sawicki, Exams of Biology

The instructions and questions for exam i of the bme 201 course during the spring 2011 semester. The exam consists of three main questions and a bonus, with a total of 120 points available. The questions involve extracting specific information from matrices, using loops, and performing element-wise multiplication. Students are allowed to use a calculator and scratch paper during the exam.

Typology: Exams

2010/2011

Uploaded on 03/31/2011

goalie4eva
goalie4eva 🇺🇸

31 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EXAM I - BME 201 - SPRING 2011
Instructions: You will have 55 minutes to complete the 3 questions below and the
Bonus. There are a total of 120 points available. Partial credit will be awarded if
your scratch work is organized neatly. Commenting your code is not required, but
will help us to award points when possible. You may use a calculator when
needed. Scratch paper is available at the front of class. Good luck!
Question 1. (30 pts):
k = 2;
A = [12 6 8 4; 3 5 1 13; 4 0 7 2]’;
a. Write out the matrix A as specified above? (5 pts.)
b. Write Matlab code to extract the third column of the matrix A and set it equal to a
variable called third_column. What is the value of third_column ? (5 pts.)
c. Write Matlab code to extract values from A to create a column vector called
diag_vec that is comprised of the elements along a diagonal spanning from the
bottom left element of A to the (2,3) element of A. What is the value of diag_vec
? (5 pts.)
d. Write Matlab code to extract the first three elements of the second column of A
and store them in a column vector called short_col. What is the value of short_col
? (5 pts.)
e. What will the Matlab command mult1 = short_col .* [ 2; 4; 6;] set mult1 equal to?
(5 pts.)
f. What will the Matlab command mult2 = A(1, :)* A(k-1:k+1,3) set mult2 equal to?
(5 pts.)
Question 2 (40 pts.):
updown = [2, 1, 5, 6, 7];
time = [1, 2, 3, 4, 5];
a. Write Matlab code using a while loop to determine endtime, the value of the array
time when the value of the array updown is both above 5 and increasing. Be sure
your code is flexible enough to do this for updown arrays of any length (20 pts).
b. Track the values in your code to verify it returns the correct answer (20 pts).
pf2

Partial preview of the text

Download Exam I - BME 201 - Spring 2011: Instructions and Questions - Prof. Gregory Sawicki and more Exams Biology in PDF only on Docsity!

EXAM I - BME 201 - SPRING 2011

Instructions: You will have 55 minutes to complete the 3 questions below and the Bonus. There are a total of 120 points available. Partial credit will be awarded if your scratch work is organized neatly. Commenting your code is not required, but will help us to award points when possible. You may use a calculator when needed. Scratch paper is available at the front of class. Good luck!

Question 1. (30 pts):

k = 2; A = [12 6 8 4; 3 5 1 13; 4 0 7 2]’;

a. Write out the matrix A as specified above? (5 pts.)

b. Write Matlab code to extract the third column of the matrix A and set it equal to a variable called third_column. What is the value of third_column? (5 pts.)

c. Write Matlab code to extract values from A to create a column vector called diag_vec that is comprised of the elements along a diagonal spanning from the bottom left element of A to the (2,3) element of A. What is the value of diag_vec ? (5 pts.)

d. Write Matlab code to extract the first three elements of the second column of A and store them in a column vector called short_col. What is the value of short_col ? (5 pts.)

e. What will the Matlab command mult1 = short_col .* [ 2; 4; 6;] set mult1 equal to? (5 pts.)

f. What will the Matlab command mult2 = A (1, :)* A(k-1:k+1,3) set mult2 equal to? (5 pts.)

Question 2 (40 pts.):

updown = [2, 1, 5, 6, 7]; time = [1, 2, 3, 4, 5];

a. Write Matlab code using a while loop to determine endtime , the value of the array time when the value of the array updown is both above 5 and increasing. Be sure your code is flexible enough to do this for updown arrays of any length (20 pts).

b. Track the values in your code to verify it returns the correct answer (20 pts).

Question 3. (40 pts):

counter=1; imagedata=[1 0 3 0];

for i=1:length(imagedata)

if imagedata(i)== iszero(counter)=i; counter=counter+1; end

i,counter end iszero

a. For the code above, track the values of i and counter at the location marked by the arrow. Mark your values in a tracking table (started for you below) where each row contains the values i and counter at each pass until the code stops (20 pts.)

Pass # (^) i counter 1 1 1

b. What is the final value of iszero that is displayed to the screen when the last line of code is executed? (20 pts.)

BONUS (20 pts.):

x=[2,4,7,9]; y=3; z=[4 5 2 6 ; 3 7 2 4 ; 5 9 8 4 ; 1 1 6 3 ] ;

N=length(z(:,1))-2;

for k=1:length(x) ; for n=1:N ww = z(n,k)*y + x(k); k n ww

end

end

For the code above, create a tracking table and fill in the rows with the current values of k, n and ww for the first five passes at the marked location.