How to select the first letter of every word

5 vues (au cours des 30 derniers jours)
Krish Desai
Krish Desai le 5 Déc 2015
Commenté : Krish Desai le 10 Déc 2015
I have no idea how I would go about doing this
Input: I like eating pizza Output: Ilep

Réponse acceptée

Mohammad Abouali
Mohammad Abouali le 5 Déc 2015
Modifié(e) : Mohammad Abouali le 5 Déc 2015
str='I like eating pizza';
str2=cellfun(@(c) c(1),strsplit(str))
  6 commentaires
Krish Desai
Krish Desai le 10 Déc 2015
Also how would I be able to eliminate extra spaces? For instance if the input was ' I like eating pizza'?
Krish Desai
Krish Desai le 10 Déc 2015
Function strtrim to fix this problem.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by