File Exchange

image thumbnail


version (2.53 KB) by

Copies the contents of a matrix to the CLIPBOARD.



View License

Editor's Note: This file was a File Exchange Pick of the Week

MAT2CLIP(A) copies the contents of 2-D matrix A to the system clipboard. A can be a numeric array (floats, integers, logicals), character array, or a cell array. The cell array can have mixture of data types.
Each element of the matrix will be separated by tabs, and each row will be separated by a NEWLINE character. For numeric elements, it tries to preserve the current FORMAT. The copied matrix can be pasted into spreadsheets.

OUT = MAT2CLIP(A) returns the actual string that was copied to the clipboard.

MAT2CLIP(A, DELIM) uses DELIM as the delimiter between columns. The default is tab (\t).

  format long g
  a = {'hello', 123;pi, 'bye'}
  % paste into a spreadsheet

  format short
  data = {
    'YPL-320', 'Male', 38, true, uint8(176);
    'GLI-532', 'Male', 43, false, uint8(163);
    'PNI-258', 'Female', 38, true, uint8(131);
    'MIJ-579', 'Female', 40, false, uint8(133) }
  % paste into a spreadsheet

  mat2clip(data, '|'); % using | as delimiter

Comments and Ratings (8)


KV (view profile)


ted p teng

ted p teng (view profile)

This will save me lots of time! Thank you!!! Why have I not checked FEX earlier! :D


Jay (view profile)


Arthur (view profile)

Excellent, simple and effective. Thanks much


Aki (view profile)

Christine Acou

Extremely useful. I used it for numeric tables with a text header, and it worked perfectly. Thanks a lot for sharing!

Mathias Kals

Anthony Baer

very useful


Updated license


Now works with all numeric data types. Added option to specify delimiter character. Updated license.

MATLAB Release
MATLAB 7.1.0 (R14SP3)

Inspired by: num2clip: copy numerical arrays to clipboard

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video