How to select the first letter of every word

2 visualizzazioni (ultimi 30 giorni)
I have no idea how I would go about doing this
Input: I like eating pizza Output: Ilep

Risposta accettata

Mohammad Abouali
Mohammad Abouali il 5 Dic 2015
Modificato: Mohammad Abouali il 5 Dic 2015
str='I like eating pizza';
str2=cellfun(@(c) c(1),strsplit(str))
  6 Commenti
Krish Desai
Krish Desai il 10 Dic 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 il 10 Dic 2015
Function strtrim to fix this problem.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by