File Exchange

image thumbnail

num2clip: copy numerical arrays to clipboard

version (821 Bytes) by Grigor Browning
Copies a numerical array to the clipboard as a tab-separated string ready for pasting.


Updated 14 Sep 2005

No License

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

A basic extension to the existing MATLAB function clipboard.m. This function allows a numerical array of any size to be copied to the clipboard ready for pasting (to say Word or Excel).

The array is copied as a tab-separated string with carriage-returns separating subsequent rows.

I suspect someone may have created this already but I can't find anything on the exchange. Sorry if I am duplicating code.

Cite As

Grigor Browning (2021). num2clip: copy numerical arrays to clipboard (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (27)

Toyofumi Yamauchi

Zhichao Guo

Geoffrey Akien

Works great - ridiculous that this still has to exist!

Ben Cogswell

Works perfect, no issues!


Thank you! Works great! Your function is an enrichment that should be included into Matlab!

Molly Adam

This works great! Thanks! I used in a GUI for a button / call back function.

great!! thanks!

Ilya Belevich


Thiago Petersen

Thank you bro!

Ricky Lange

Thanks for this. I just added a

for i = 1:size(arraystring,1)
arraystring(i,:) = strrep(arraystring(i,:),'.',',');

after line 19 to deal with the German decimal point characteristics.
Pasting in Excel works perfect now!


Good. Works as stated. I only altered num2str() to increase the output precision.

Nikolaj Jensen

Nelson Cortes

Corinne Jones

This is life-changing.


Tsun Holt Wong

Fantastic, but is there a way to increased the accuracy of the copied data?

When I paste very long numbers in, it gets cut down to only 5 sig figs. Whereas the normal clipboard command keeps many more.



Exactly what I needed, thanks!

Igor Cvetkovic

Craig Cowled

Very nice, thank you. This saves me a lot of time.

Laila h

this is awesome.. thank you :D

Jon Petter Grandal

Working excellent! This saves me a lot of work. Thanks!

Mink H

Nothing wrong, it just works!!
I pasted directly into excel with no problems.
Keep it up!

Gabriele Bulian

I had to change the line:
arraystring = num2str(array');
arraystring = num2str(array,'%100e');
otherwise I had some problems in making excel recognise the data...

Gerd Kunert

The idea is nice.
However, Excel has very strange ways to open files and to import data (depending e.g. on your language).
In other words, the pasted data may be formatted in an "arbitrary" way. In my case, values were simply not correct.

Conclusion: Use xlswrite to export data to Excel. Otherwise fine.

James J. Cai

MATLAB Release Compatibility
Created with R14SP2
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!