{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS1371_Practice_Test_2_Fall07

# CS1371_Practice_Test_2_Fall07 - CS 1371 Test Team Presents...

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

CS 1371 Test Team Presents: Practice Test II – Fall 2007 Problem 1 - Structures A. Given the following MATLAB script: x1 = struct('Place', 'USA', 'Population', 301000000); x2 = struct('Place', 'Georgia', 'Population', 9000000, 'Location', x1); x3 = struct('Place', 'Atlanta', 'Population', 4000000, 'Location', x2); x4 = setfield(x3, 'Place', 'Savannah'); x4.Population = 130000; cities = [x3 x4]; cities(3).Team = 'Braves'; rmfield(x3, 'Location'); varA = isfield(cities(1), 'Team') varB = fieldnames(x3) varC = [getfield(cities(2), 'Population'), getfield(cities(3), 'Population')] varD = cities(2).Location.Location.Place varE = class(x4.Location) What is the final value of the following variables after the script above is executed in MATLAB? 1. varA = A. 0 B. 1 C. 2 D. Error E. None of the above 2. varB = A.{‘Place’ ‘Population’} B. {‘Place’, ‘Population’, ‘Location’} C. {‘Place’, ‘Population’, ‘Team’} D.{‘Place’, ’Population’, ’Location’, ’Team’} E. None of the above 3. varC = A. [4000000] B. [130000] C. [13000 0] D. Error E. None of the above 4. varD = A. ‘USA’ B. ‘Georgia’ C. 1x1 struct D. Error E. None of the above 5. varE = A. ‘var’ B. ‘char’ C. ‘struct’ D. Error E. None of the above B. Write a function called structToVec that takes in a structure array and a fieldname and returns a vector of the values in that field for each structure. You may assume that only numeric data is stored in the input structure array.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

CS1371_Practice_Test_2_Fall07 - CS 1371 Test Team Presents...

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

View Full Document
Ask a homework question - tutors are online