Today you'll be working in pairs to write code for these two tasks. The goal is to strengthen your string manipulation skills in MATLAB.
Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliet Kilo Lima
Mike November Oscar Papa Quebec Romeo Sierra Tango Uniform Victor Whiskey
X-ray Yankee Zulu
Your function can only have one loop: the loop through the given string.
Here are some examples:
>> result1 = translatePhonetic('Sohie') result1 = Sierra Oscar Hotel India Echo >> result2 = translatePhonetic('elmo') result2 = Echo Lima Mike Oscar >> result3 = translatePhonetic('cs112') result3 = Charlie Sierra >> result4 = translatePhonetic() Please enter a string for phonetic translation result4 = '' >> result5 = translatePhonetic('flower') result5 = Foxtrot Lima Oscar Whiskey Echo Romeo >> result6 = translatePhonetic(result5(1:9)) result6 = Foxtrot Oscar X-ray Tango Romeo Oscar Tango >>
>> res = containsDuplicate('simon') res = 0 >> res = containsDuplicate('ellen') res = 1 >> res = containsDuplicate('kara') res = 1 >> res = containsDuplicate('randy') res = 0 >> res = containsDuplicate('american') res = 1 >> res = containsDuplicate('encyclopedia') res = 1 >> res = containsDuplicate('I am ') res = 1 >> res = containsDuplicate('uncopyrightable') res = 0 >> res = containsDuplicate('dermaglyphics') res = 0 >> res = containsDuplicate('!@\#$') res = 0
containsDuplicate
so that it has the same functionality, but uses a for loop instead of a while loop.
Here's a hint about the undo button. Everytime MATLAB makes a plot, it stores a handle to that plot. If you save all the handles each time something is plotted, then you can use those handles to undo.
Here is an example:
>> h1 = plot(1:10) h1 = 171.0045 >> hold on >> h2 = plot(10:-1:1,'m*:') h2 = 172.0040>> delete(h1) >>
![]()