L19post

# L19post - Previous Lecture Cell arrays Todays Lecture More...

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

± 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

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

View Full Document
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
November 3, 2009 Lecture 19 3 Example 1904 = 1*1000 + 9*100 + 0*10 + 4*1 = M CM IV = MCMIV

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

View Full Document
November 3, 2009 Lecture 19 4 1 9 0 4 MCMIV
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’

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

View Full Document
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
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

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

View Full Document
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
November 3, 2009

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 / 36

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

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

View Full Document
Ask a homework question - tutors are online