How to save table in workspace as txt/.m file in matlab ?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
Table is a variable containing 99*1 double values saved in workspace. I need to convert it into txt/.m file
0 Kommentare
Antworten (1)
Kirby Fears
am 23 Mai 2016
Bearbeitet: Kirby Fears
am 23 Mai 2016
You can use writetable to write to a text file.
writetable(data,'outputfile.txt');
If you really need this to be a .m file, you can make a new copy as .m and delete the original file.
copyfile('outputfile.txt','outputfile.m');
delete('outputfile.txt');
2 Kommentare
Kirby Fears
am 5 Jan. 2017
Bearbeitet: Kirby Fears
am 5 Jan. 2017
Abhishek,
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.
csvwrite('outputfile.txt',magic(10));
If you want the result to be .m format, just indicate the file name accordingly:
csvwrite('outputfile.m',magic(10));
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!