L19post - Previous Lecture: Cell arrays Todays Lecture:...

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

View Full Document Right Arrow Icon
± Previous Lecture: ± Cell arrays ± Today’s Lecture: ± More on cell arrays ± Structures ± Structure array (i.e., an array of structures) ± A structure with array fields (next lecture) ± Announcements: ± Project 5 due Thursday at 11pm ± Section this week in the computer lab (UP B7) ± Review session this Sunday. Location and time TBA. ± Prelim 2 next Tuesday, Nov 10 th
Background image of page 1

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

View Full DocumentRight Arrow Icon
November 3, 2009 Lecture 19 2 C{1} = ‘I’ C{2} = ‘II’ C{3} = ‘III’ : C{2007} = ‘MMVII’ : C{3999} = ‘MMMXMXCIX’ Example: Build a cell array of Roman numerals for 1 to 3999
Background image of page 2
November 3, 2009 Lecture 19 3 Example 1904 = 1*1000 + 9*100 + 0*10 + 4*1 = M CM IV = MCMIV
Background image of page 3

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

View Full DocumentRight Arrow Icon
November 3, 2009 Lecture 19 4 1 9 0 4 MCMIV
Background image of page 4
November 3, 2009 Lecture 19 5 ‘’ C CC CCC CD D DC DCC DCCC CM ‘’ X XX XXX XL L LX LXX LXXX XC ‘’ I II III IV V VI VII VIII IX ‘’ M MM MMM 1 9 0 4 Concatenate entries from these cell arrays! ‘M’ concat. ‘CM’ concat . ‘’ concat . ‘IV’
Background image of page 5

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

View Full DocumentRight Arrow Icon
November 3, 2009 Lecture 19 6 Ones-Place Conversion function r = Ones2R(x) % x is an integer that satisfies % 0 <= x <= 9 % r is the Roman numeral with value x. Ones = {'I', 'II', 'III', 'IV', . .. 'V', 'VI','VII', 'VIII', 'IX'}; if x==0 r = ''; else r = Ones{x}; end
Background image of page 6
November 3, 2009 Lecture 19 7 Ones-Place Conversion function r = Ones2R(x) % x is an integer that satisfies % 0 <= x <= 9 % r is the Roman numeral with value x. Ones = {'I', 'II', 'III', 'IV', . .. 'V', 'VI','VII', 'VIII', 'IX'}; if x==0 r = ''; else r = Ones{x}; end
Background image of page 7

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

View Full DocumentRight Arrow Icon
November 3, 2009 Lecture 19 8 Similarly, we can implement these functions: function r = Tens2R(x) % x is an integer that satisfies % 0 <= x <= 9 % r is the Roman numeral with value 10*x. function r = Hund2R(x) % x is an integer that satisfies % 0 <= x <= 9 % r is the Roman numeral with value 100*x function r = Thou2R(x) % x is an integer that satisfies % 0 <= x <=3 % r is the Roman numeral with value 1000*x
Background image of page 8
November 3, 2009
Background image of page 9

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

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

Page1 / 36

L19post - Previous Lecture: Cell arrays Todays Lecture:...

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

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