CS1371_Practice_Test_2_Solutions_Fall07

CS1371_Practice_Test_2_Solutions_Fall07 - end Problem 4 -...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 1371 Test Team Presents: Practice Test II Solutions – Fall 2007 Problem 1 - Structures A. 1. varA = B. 1 2. varB = B. {‘Place’, ‘Population’, ‘Location’} 3. varC = B. [130000] 4. varD = A. ‘USA’ 5. varE = C. ‘struct’ B. function vec = structToVec(SA, field) vec = []; for index = 1:length(SA) vec = [vec getfield(SA(index), field)]; end
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem 2 - File I/O A. 1. num(2, 3) = D. 10 2. txt{cols, 1} = E. None of the above (It will return ‘Candidate 3’) 3. raw{rows, end} = D. 8 4. M = B. 29 5. class(raw{rows, 4}) = C. ‘double’ B. Candidate 2 is most qualified
Background image of page 2
Problem 3 - Recursion A. if x < 10 and if A < 10 B. 1. Digits(0) = A. 0 2. Digits(71) = C. 8 3. Digits(142) = E. None of the above 4. Digits(697) = B. 4 C. function ret = PairSum(vec) if isempty(vec) ret = []; elseif length(vec) == 1 ret = vec; else ret = [(vec(1) + vec(end)) PairSum(vec(2:end-1))];
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end Problem 4 - Plotting A. -10-8-6-4-2 2 4 6 8 10-10-8-6-4-2 2 4 6 8 10 Bull's Eye! x-axis y-axis Note: For solution to be completely correct, your answer MUST include the x and y labels, and the title. B. function mirror(x, y, z) plot3(x, y, z, 'b') hold on plot3(-x, -y, z, 'r') xlabel('x-axis') ylabel('y-axis') zlabel('z-axis') title('Mirror Functions') Problem 5 - Bodies of Rotation A. u = linspace(0,10,100); v = sin(u); th = linspace(0, 2*pi , 100); [uu tth] = meshgrid(u, th); [vv tth] = meshgrid(v, th); subplot(1,2,1) radius = vv xx1 = uu yy1 = radius.*cos(tth); zz1 = radius.*sin(tth) ; surf (xx1, yy1, zz1) B. subplot(1,2,2) radius2 = uu; xx2 = radius2.*cos(tth); yy2 = radius2.*sin(tth); zz2 = vv; mesh(xx2,yy2,zz2) Thanks to Jacey Planteen for her help on this test. Last Modified: 10:36PM, October 21 st 2007 by Shardul Bhatia...
View Full Document

Page1 / 5

CS1371_Practice_Test_2_Solutions_Fall07 - end Problem 4 -...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online