MATLAB: Beginner – using a function to find last word of a phrase

acronymsbeginnerfunctions

I'm new to matlab, and am struggling. In this case, I am told to find a acronym function that would give the acronym of any phrase I input.
"function acr = acronym(phrase)"…..
….is given, and if evaluated correctly, typing in acronym('i love matlab') and acronym('the ball is red') both yield 'ilm' and 'tbir'.
Some guidance would be appreciated as to how to finish the acr function correctly so as to be able to yield acronyms for any phrase from one m.file. Thank you

Best Answer

str = 'I am new to matlab, and am struggling.'
theWords = allwords(str)
strArray=char(theWords{:})
theAcronym = strArray(:,1)'