strtruncpad#
Purpose#
Truncates all elements of a string array to the specified number of characters, adding spaces on the end as needed to achieve the exact length.
Format#
- y = strtruncpad(sa, maxlen)#
- Parameters:
sa (NxK string array) – data
maxlen (1xK or 1x1 matrix) – maximum length.
- Returns:
y (NxK string array) – contains contents of sa with all elements of truncated to the number of characters in maxlen.
Examples#
sa = "Hello" $| "Hi";
// Truncate or pad to exactly 8 characters
y = strtruncpad(sa, 8);
print y;
print (strlen(y));
The code above produces the following output:
Hello
Hi
8.0000000
8.0000000
See also
Functions strtriml(), strtrimr(), strtrunc(), strtruncl(), strtruncr()