# RED - Section A: Creating Vectors Question 1: Which of the...

This preview shows pages 1–3. Sign up to view the full content.

CSE 131 Final Exam, Fall 2005 (RED version) Page 2 of 12 Section A: Creating Vectors Question 1: Which of the following choices will generate a vector p whose elements are the following? -3, 3, 9 a) p = linspace(-3, 3, 9) b) p = linspace(3, -3, 9) c) p = linspace(-3, 9, 3) d) p = linspace(9, 3, -9) Question 2: Which of the following choices will generate a vector p whose elements are the following? -3, 3, 9 a) p = -3:3:9 b) p = -3:6:9 c) p = -3:9:6 d) p = -3:9:3 Section B: Array FETCH Operations Question 3: After the following code fragment is run, what is the value of y? x = [1,2,3; 4,5,6; 7,8,9]; y = x([1,2], end-1:end) a) [2,3,5,6] b) [1,2;3,4] c) [2,3; 5,6] d) [1,2,3; 4,5,6] Question 4: After the following code fragment is run, what is the value of y? z = [1,2; 2,1]; y = [z(1,:); z(:,2)'] a) [1,2; 2,1] b) [1,2,2,1] c) [1,2,1,2; 2,1,2,1] d) [2,1; 1,2]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CSE 131 Final Exam, Fall 2005 (RED version) Page 3 of 12 Question 5: After the following code fragment is run, what is the value of p? x = [7,2,3; 0,4,8; 5,6,1]; p = x(1,2)*x(2,:) + x(end,:) a) [0,8,16] b) [0,8,17] c) [5,14,25] d) [5,14,17] Question 6: After the following code fragment is run, what is the value of z? x = [10,100;50,100]; y = x'; z = [x(:,end)'; y(end,:)]' a) [100,100; 100,100] b) [10,50; 10,50] c) [100,100,100,100] d) [100,100; 100,10] Question 7: After the following code fragment is run, what is the value of x? y = 'Ashley Ohio is my home.'; x = y(1, 8:12) a) Ashley b) Ohio c) home d) none of the above Section C: Array SET Operations Question 8: After the following code fragment is run, what is the value of x? x = [1, 2, 3; 4, 5, 6; 7, 8, 9]; y = [4, 5, 6; 7, 8, 9; 1, 2, 3]; x(end, :) = y(:, end)' a) [1, 2, 3; 4, 5, 6; 1, 2, 3] b) [1, 2, 3; 4, 5, 6; 7, 8, 9] c) [1, 2, 3; 4, 5, 6; 6, 9, 3] d) [1, 2, 6; 4, 5, 9; 7, 8, 3] Question 9: After the following code fragment is run, what is the value of y?
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 03/19/2008 for the course CSE 131 taught by Professor Sticklen during the Spring '08 term at Michigan State University.

### Page1 / 9

RED - Section A: Creating Vectors Question 1: Which of the...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online