L18post - Previous Lecture: Characters and strings Todays...

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

View Full Document Right Arrow Icon
± Previous Lecture: ± Characters and strings ± Today’s Lecture: ± Cell arrays ± Announcement: ± Project 5 due Thursday 10/5 at 11pm ± Prelim 2 on Nov 10. Email Randy Hess ( rbhess@cs.cornell.edu ) if you have a conflict.
Background image of page 1

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

View Full DocumentRight Arrow Icon
October 29, 2009 Lecture 18 2 Example: toUpper Write a function toUpper(cha) to convert character cha to upper case if cha is a lower case letter. Return the converted letter. If cha is not a lower case letter, simply return the character cha . Hint : Think about the distance between a letter and the base letter ‘ a ’(or± A ’). E.g., a b c d e f g h … A B C D E F G H … Of course, do not use Matlab function upper ! distance
Background image of page 2
October 29, 2009 Lecture 18 3 Example: censoring words function C = censor(str, A) % Replace all occurrences of string str in % character matrix A with X’s, regardless of % case. % Assume str is never split across two lines. % C is A with X’s replacing str. A U s M A T L A B e i n t h a t l a b . U s M A T X X X e i n t h a t X X X . C c e n s o r l a b
Background image of page 3

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

View Full DocumentRight Arrow Icon
October 29, 2009 Lecture 18 8 Matrix vs. Cell Array 3.1 2 -1 9 1.1 ‘c’ ‘o’ ‘m’ ‘’ ‘s’ ‘1’ ‘1’ ‘1’ ‘2’ ‘’ ‘’ ‘’ ‘L’ ‘A’ ‘B’ ‘M’ ‘a’ ‘t’ ‘’ ‘’ Vectors and matrices store
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

L18post - Previous Lecture: Characters and strings Todays...

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

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