File Exchange

image thumbnail


version (4.82 KB) by John Colby
Generates paste-able ASCII representations of MATLAB variables


Updated 05 Dec 2011

View License

This function emulates the R version of dput(). It writes ASCII representations of variables that can be easily pasted back into MATLAB and evaluated to recreate the variables. This is especially useful for quickly posting short reproducible examples on sites like Stack Overflow, without having to upload any separate data files as attachments, and while overcoming the shortcomings of the "save -ascii" approach.

One particularly useful highlight is that dput can flexibly handle generic recursion into structure and cell arrays. It will work through these objects, repeatedly calling itself, to eventually capture their entire organization down to their basic elements.

Cite As

John Colby (2020). dput (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)


wonderful tool

John Colby

Thanks, Christie! I put the change on github, and it should be updated here by tomorrow.

in your submission example you have:
mystruct = mystruct = struct('index', num....
it should be mystruct = struct('......


Added support for logical, integer, complex double data types. Added option to specify desired precision. Added xUnit tests.

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