Main Content

clipboard

Copy and paste text to and from system clipboard

Description

example

clipboard('copy',data) copies the specified data to the clipboard.

Note

The clipboard function requires Oracle® Java® software.

example

contents = clipboard('paste') returns the current contents of the clipboard. If clipboard is unable to retrieve the contents of the clipboard, contents is empty ('').

example

importedcontents = clipboard('pastespecial') imports the contents of the clipboard using the Import Tool.

Examples

collapse all

Copy a line of text into the clipboard and then paste it into an array.

clipboard('copy', 'This is the text that I want to copy');
contents = clipboard('paste')
contents = 
'This is the text that I want to copy'

Copy data into the clipboard and then import the clipboard data into MATLAB®.

Select the lines below, right-click, and then select Copy.

1,2,3
4,5,6
7,8,9

Import the clipboard data into MATLAB using the clipboard function. The Import Wizard opens.

A = clipboard('pastespecial')

In the Import Wizard, click Next and then Finish to import the contents of the clipboard into A.

Input Arguments

collapse all

Data to copy, specified as a numeric array, character vector, or string scalar.

Output Arguments

collapse all

Contents of the clipboard, returned as a character vector.

Contents of the clipboard imported from the Import Tool, returned as a structure array.

Introduced before R2006a