strtrunc#

Purpose#

Truncates all elements of a string array to not longer than the specified number of characters.

Format#

y = strtrunc(sa, maxlen)#
Parameters:
  • sa (NxK string array) – data

  • maxlen (1xK or 1x1 matrix) – maximum length.

Returns:

y (NxK string array) – contains contents of sa truncated to length specified by maxlen.

Examples#

string s = { "best", "linear", "unbiased", "estimator" };
ss = strtrunc(s, 6);

After the code above, the variables s and ss are equal to:

        best
      linear
s = unbiased
   estimator

        best
      linear
ss =  unbias
      estima