Code covered by the BSD License  

Highlights from
MAT2CLIP

5.0

5.0 | 5 ratings Rate this file 22 Downloads (last 30 days) File Size: 2.53 KB File ID: #8559
image thumbnail

MAT2CLIP

by Jiro Doke

 

26 Sep 2005 (Updated 29 Dec 2009)

Copies the contents of a matrix to the CLIPBOARD.

Editor's Notes:

This file was a File Exchange Pick of the Week

| Watch this File

File Information
Description

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).

Example:
  format long g
  a = {'hello', 123;pi, 'bye'}
  mat2clip(a);
  % 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) }
  mat2clip(data);
  % paste into a spreadsheet

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

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
num2clip: copy numerical arrays to clipboard

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
31 Jan 2006 Anthony Baer

very useful

30 Mar 2007 Mathias Kals  
27 Apr 2008 Christine Acou

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

09 Jun 2009 Aki  
25 Feb 2011 Arthur

Excellent, simple and effective. Thanks much

21 May 2012 Jay  
Please login to add a comment or rating.
Updates
29 Dec 2009

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

Tag Activity for this File
Tag Applied By Date/Time
data import Jiro Doke 22 Oct 2008 08:00:48
data export Jiro Doke 22 Oct 2008 08:00:48
copy Jiro Doke 22 Oct 2008 08:00:48
clipboard Jiro Doke 22 Oct 2008 08:00:48
matrix Jiro Doke 22 Oct 2008 08:00:48
spreadsheet Jiro Doke 22 Oct 2008 08:00:48
format Jiro Doke 22 Oct 2008 08:00:48
excel Jiro Doke 22 Oct 2008 08:00:48
cell Jiro Doke 22 Oct 2008 08:00:48
array Arthur 25 Feb 2011 19:15:30
numeric Arthur 25 Feb 2011 19:15:43

Contact us at files@mathworks.com