File Exchange

image thumbnail

Capitalize strings using titlecase

version 1.1.0.0 (1.36 KB) by Brandon Kuczenski
Capitalize the first letter of each word in a string or cell array of strings

1 Download

Updated 23 Sep 2013

View License

This function capitalizes each word in a string, or in a cell array of strings, excepting a user-definable set of short words. The default non-capitalized words are 'a', 'an', 'and', 'or', 'the', and 'in'.

Example:

>> C={'a walk in the park' 'two birds with one stone' 'pay the piper'}';
>> capitalize(C)

ans =

'A Walk in the Park'
'Two Birds With One Stone'
'Pay the Piper'

>> capitalize(C,{'with','THE'})

ans =

'A Walk In the Park'
'Two Birds with One Stone'
'Pay the Piper'

>>

Comments and Ratings (2)

Yee Jack

nice work!!!

Updates

1.1.0.0

Corrected silly error that caused the function to fail for single-word inputs.

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux