initialcaps

Convert a string to initial caps format (initial capitals on all words).

이 제출물을 팔로우합니다

INITIALCAPS Convert string to "initial caps" format (initial capitals on all words).
B = INITIALCAPS(A) converts the initial letter of all words in A to capitals, where A is a string. Only initial letters are affected.

B = INITIALCAPS(A,idx) converts only the words in A indexed by vector 'idx' to "initial caps" format. A "word" for these purposes is any string of letters separated by one or more non-letters, excluding apostrophes. Thus, the phrase
"don't talk to grown-ups" contains 5 words.

Examples: A = 'life, don''t talk to me about life.'
y = initialcaps(A)
y =
Life, Don't Talk To Me About Life.

y = initialcaps(A,1)
y =
Life, don't talk to me about life.

y = initialcaps(A,[2 3])
y =
life, Don't Talk to me about life.

y = initialcaps(A,[2,5:7])
y =
life, Don't talk to Me About Life.

Acknowledgments: Thanks to Jerome from France for the vectorized code (vastly nicer than my original clunker), and thanks to John D'Errico for the suggestion regarding inclusion of a second input argument.

See also UPPER, LOWER, HEADLINE.

인용 양식

David Fass (2026). initialcaps (https://kr.mathworks.com/matlabcentral/fileexchange/12432-initialcaps), MATLAB Central File Exchange. 검색 날짜: .

카테고리

Help CenterMATLAB Answers에서 Characters and Strings에 대해 자세히 알아보기

일반 정보

MATLAB 릴리스 호환 정보

  • 모든 릴리스와 호환

플랫폼 호환성

  • Windows
  • macOS
  • Linux
버전 퍼블리시됨 릴리스 정보 Action
1.0.0.0

Vectorization courtesy of Jerome. Added second input argument.
Update for BSD license.