Filter löschen
Filter löschen

How to select the first letter of every word

9 Ansichten (letzte 30 Tage)
Krish Desai
Krish Desai am 5 Dez. 2015
Kommentiert: Krish Desai am 10 Dez. 2015
I have no idea how I would go about doing this
Input: I like eating pizza Output: Ilep

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by