Final_Practice_questions

Final_Practice_questions - E7 Spring 2008 Final Practice...

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

View Full Document Right Arrow Icon
E7 Spring 2008 Page 1 of 11 Final Practice Questions Array, data structures / matrix operation A - Array Operation 1. Assign a new value to row 4 column 3 in the array M. 2. Create an array M that has m columns and n rows that are all zeros. 3. You have an array M that represents three properties, X, Y, and Z each as a column of data. Reference all of the values for only properties X and Z for purposes of plotting. B- Data Structure 1. Create a structure array with 4 cells each containing 2 types of data. 2. Re-assign one of the data values. Relational operators/logical variables/conditional statements (a) if y > 5 w = y + 8; elseif y > 15 w = y; else w = y*2 -1; end w Which number in the array y = [1 3 5] will generate itself when passed through this loop? Answer = 1 (b) X = [2 3 4]; Y= [3 3 3]; (i) Z= (X ~=Y) Ans: Z = 1 0 1 (ii) Z=(X>2) & (Y>1) Ans: Z = 0 1 1 (iii) Z= (X+2) | (Y-1) Ans: Z = 1 1 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
E7 Spring 2008 Page 2 of 11 Final Practice Questions Loops Fill in the blanks in the following function so that it runs as described in the comments. % This function prints out every other member, by row, of a % given input array, 'array'. For example, the input % [1,2,3,4;5,6,7,8] would return [1,3;5,7]. function EOArray = PrintEveryOther(array) [m,n] = size(array) EOArray=zeros(m,(ceil(n/2))); %'j' stores the index of each row that we want to include % in 'EOArray' from 'array'. j=_______________ for k=________________ for p=_________________ EOArray(k,p)=___________________ end end return Graphics Topic 1: Using handles with get and set methods Let’s say hFig is a handle to a plot in Matlab and you type >> get(hFig) into the command window, which yields the following output: Alphamap = [ (1 by 64) double array] BackingStore = on CloseRequestFcn = closereq Color = [0.8 0.8 0.8] Colormap = [ (64 by 3) double array] CurrentAxes = [158.017] ... (and so on. ..) 1. What does Color: [0.8 0.8 0.8] represent? 2. How would you change the contents of the ‘Color’ field from gray to red? 3. How would you assign the red value in the color vector to a variable called RedValue?
Background image of page 2
E7 Spring 2008 Page 3 of 11 Final Practice Questions Note: you will not need to memorize field names associated with figures, plots, and axes for the final. Topic 2: Plot and subplot commands, plotting styles, plot labeling, plot legends 4. Given the following code: >> x = 0:0.1:5; >> y = x.^3; How would you plot the function using blue asterisks? 5.
Background image of page 3

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

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

This note was uploaded on 03/04/2009 for the course E 7 taught by Professor Patzek during the Spring '08 term at University of California, Berkeley.

Page1 / 11

Final_Practice_questions - E7 Spring 2008 Final Practice...

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

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