Question: Write a function LetterCounts( ), using matlab. This function has one parameter, a string. It will output a 26-element vector corresponding to the frequency of
Write a function LetterCounts( ), using matlab. This function has one parameter, a string.
It will output a 26-element vector corresponding to the frequency of the letters. You can do this by first initializing your output vector to 26 0s. Then, iterate through every character in the string, finding which letter of the alphabet that character is, and incrementing the corresponding index by 1. When you are all done, compute the actual frequency based on the length of the input string. You want the frequency values in percentages.
In other words, if I computed frequencies for the string 'aaabb' the initial vector of letter counts would be [3, 2, 0, 0, ..., 0] and the final output vector would be [60, 40, 0, 0, 0, ...., 0] indicating that 'a' appeared 60% of the time, 'b' appeared 40% of the time.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
