Problem 1383. Count letters occurence in text, specific to words with a given length.
Build a function with two input arguments: a string and a word length (number of letters), that outputs a vector of counts of the 26 letters of the alphabet, specific to words with a given length.
- Case insensitive.
- Words contain only letters a-zA-Z, but the string can contain punctuation.
Example
 >> txt = 'Hello World, from MATLAB' ;
 >> nl  = 5 ;                              % Number of letters.
 >> nlWords_getCounts(txt, nl)
 ans = 
     0  0  0  1  1  0  0  1  0  0  0  3  0  0  2  0  0  1  0  0  0  0  1  0  0  0here, two 5 letters words are found: 'Hello' and 'World'. The output vector is the count of letters (1 to 26) in these two words taken together. For example, letter 12 is 'l/L' and we see that it appears 3 times, hence the count of 3.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers179
Suggested Problems
- 
         Test if two numbers have the same digits 253 Solvers 
- 
         Matrix multiplication across rows 376 Solvers 
- 
         
         1828 Solvers 
- 
         (Linear) Recurrence Equations - Generalised Fibonacci-like sequences 365 Solvers 
- 
         
         6869 Solvers 
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!