pad
Add leading or trailing characters to strings
Syntax
Description
adds space characters to the ends of the strings in newStr
= pad(str
)str
, except
for the longest one.
If
str
is a string array or cell array of character vectors with multiple elements, thenpad
adds space characters. All of the strings innewStr
are as long as the longest element instr
.If
str
is a character vector, or a string array or cell array of character vectors with one element, thenpad
returnsstr
unaltered.
adds space characters so the strings in newStr
= pad(str
,numberOfCharacters
)newStr
have the length
specified by numberOfCharacters
. If any strings in
str
have more characters than
numberOfCharacters
, then pad
does not
modify them.
adds space characters to the side specified by newStr
= pad(str
,numberOfCharacters
,side
)side
, up to the
length specified by numberOfCharacters
.
pads strings with the character specified by newStr
= pad(___,padCharacter
)padCharacter
instead
of the space character. You can use any of the input arguments in the previous
syntaxes.
If str
contains only one piece of text, then
pad(str,padCharacter)
returns str
unaltered.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2016b