blanks - Create character array of blanks - MATLAB (original) (raw)

Main Content

Create character array of blanks

Syntax

Description

Note

pad is recommended overblanks because it provides greater flexibility and allows vectorization. For additional information, see Alternative Functionality.

chr = blanks([n](#bvjtc50-n)) returns a1-by-n array of space characters.

example

Examples

collapse all

Create an array of five blanks. To display it, embed it in a character array that starts and ends with a visible character.

b = blanks(5); chr = ['|' b '|']

Embed the blanks in a string and display the string. You can create strings using double quotes.

str = "Due Date:" + b + "2017-01-13"

str = "Due Date: 2017-01-13"

Input Arguments

collapse all

Number of space characters, specified as an integer.

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Alternative Functionality

Update code that makes use of blanks to use pad instead. Unlike blanks, which creates a new character vector of whitespace characters, pad adds whitespace characters to an existing piece of text and returns the same data-type as the input. For example:

Not Recommended Recommended
str = blanks(5) str = ' ' str = pad("",5) str = " "

Extended Capabilities

Version History

Introduced before R2006a