t3review1 - suit and rank that store the appropriate...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Review questions for Prelim 3 1. Write the following function: function [len, ind] = longest(C) % Find the longest string(s) in cell array C. % C is an n-by-1 cell array of strings, n>=1. % len is the length of the longest string in C. % ind is a vector, possibly of length one, containing the index number(s) of % the strings with length len 2. Given the following cell arrays of strings: suits= {’Hearts’, ’Clubs’, ’Spades’, ’Diamonds’}; ranks= {’Ace’, ’2’, ’3’, ’4’, ’5’, ’6’, ’7’, ’8’, ’9’, ’10’, ’Jack’, ’Queen’, ’King’}; write a code fragment to Create a structure array of cards such that each structure has two fields,
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: suit and rank , that store the appropriate strings. The structure array should be of length 52. • Do a perfect shuffle of the cards. 3. Assume that each structure in structure array Pts has two Felds, x and y . Write a code fragment to sort the structure array Pts so that the structures are in the order of increasing distance from (0,0). You can use built-in function sort : [y, idx]= sort(x) where x is an n-vector of numbers , y is x sorted in ascending order, and idx is an n-vector of indices such that y(i) = x(idx(i)) . (Review your notes from Lecture 19 if necessary.) 4. Review the project questions, lecture examples, and section exercises! 1...
View Full 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