strjust
Justify strings
Description
Note
pad is recommended over
strjust because it provides greater flexibility and
allows vectorization. For additional information, see Alternative Functionality.
newStr = strjust( returns a
right-justified version of the text in str)str.
If
strhas trailing whitespace characters, then they become leading whitespace characters innewStr.If
strdoes not have trailing whitespace characters, thenstrjustreturnsstrunaltered.
Examples
Input Arguments
Alternative Functionality
Update code that makes use of strjust to use pad instead. If justifying text left or right, also use strip to remove whitespace from the text first. For example:
| Context | Not Recommended | Recommended |
|---|---|---|
| Right justification | strjust(A) | pad(strip(A),"left") |
| Left justification | strjust(A) | pad(strip(A),"right") |
| Center justification | strjust(A,"center") | pad(A,"both") |
Extended Capabilities
Version History
Introduced before R2006a