Final_Practice_questions - E7 Spring 2008 Final Practice...

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

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
Image of page 1

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

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?
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?
Image of page 3

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

Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern