How to save table in workspace as txt/.m file in matlab ?

30 views (last 30 days)
Table is a variable containing 99*1 double values saved in workspace. I need to convert it into txt/.m file

Answers (1)

Kirby Fears
Kirby Fears on 23 May 2016
Edited: Kirby Fears on 23 May 2016
You can use writetable to write to a text file.
If you really need this to be a .m file, you can make a new copy as .m and delete the original file.
Kirby Fears
Kirby Fears on 5 Jan 2017
Edited: Kirby Fears on 5 Jan 2017
In that case, what you have is a double array instead of a table (in Matlab parlance).
You can simply use csvwrite. Here's an example.
If you want the result to be .m format, just indicate the file name accordingly:

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by