clipboard

Copies text to the system clipboard or reads the text stored there.

Category: Environment and Settings > System Commands

Syntax

clipboard('copy', data)

Puts data on the clipboard as text.

data = clipboard('paste')

Returns the current clipboard text as a character vector.

Description

clipboard is the programmatic equivalent of copy and paste for plain text. Only text is exchanged; images and files on the clipboard are not read.

Input arguments

'copy' | 'paste'
The action to perform.
data
Text to copy. Other values are converted to their text form.

Output arguments

data
Clipboard contents as text, for 'paste'.

Example

Round trip through the clipboard

clipboard('copy', 'hello from MatLivre');
s = clipboard('paste')
Output
s = 'hello from MatLivre'

See also

disp sprintf fprintf