Write Data to .txt or .csv file?
5 次查看(过去 30 天)
显示 更早的评论
I'm trying to write data that I have in a matrix to a .txt or .csv file. I have data in a 250x2 matrix, and would simply like to be able to write this out to a file of my choice, say 'data.txt' or something like that. Is there an easy way to do this?
0 个评论
采纳的回答
Oleg Komarov
2011-8-4
4 个评论
Oleg Komarov
2011-8-4
compose the destination folder dynamically:
root = 'C:\User\Me\Documents\';
fname = 'filename.txt';
dlmwrite([root fname]...)
Image Analyst
2011-8-4
Or use fullfile
fullFileName = fullfile(root, fname);
fullfile takes care of creating the correct filename regardless of whether root has a trailing slash or not.
or sprintf
fullFileName = sprintf('%s/%s', root, fname);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!