The previous problem in this series is 44852.
Given a character array, s, representing a sentence, return a and g, the arithmetic and geometric means, respectively, of the number of letters per word in the given sentence. Round your answer to three decimal digits.
You may make the following assumptions:
1. Not all characters in the array are either letters or spaces. There may also be numeric characters, as well as punctuation.
2. There may be redundant spaces in the sentence.
3. Punctuation does not count as a letter and cannot constitute a word in itself. Numbers also do not count as letters, but can constitute a word.
4. There can be any number of characters and/or words in the sentence, including zero. When there are zero words in the sentence, return empty matrices for a and g.
Example:
c = 'The quick brown fox jumps over the lazy dog';
a = 3.889; g = 3.792
Example:
c = 'Another one bites the dust';
a = 4.400; g = 4.169
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers14
Suggested Problems
-
Find the alphabetic word product
3469 Solvers
-
1930 Solvers
-
Volume of a sphere given its surface area
155 Solvers
-
MATCH THE STRINGS (2 CHAR) very easy
301 Solvers
-
311 Solvers
More from this Author45
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!