move txt file from one folder to another
2 次查看(过去 30 天)
显示 更早的评论
Hi. I am trying to save a .TXT file inside a certain folder. I am currently using this code, but something is not working....
destdirectory = 'C:\Users\....\FolderN'
A = 300;
save(fullfile(destdirectory, 'A.txt'), 'A'); % ???
I had also thought of saving it in the current folder and moving it to the desired folder with 'movefile' but to no effect:
A = 300;
writematrix(A, 'A.txt')
destdirectory = 'C:\Users\....\FolderN';
movefile('A.txt', 'destdirectory');
0 个评论
采纳的回答
Florian Bidaud
2022-11-23
编辑:Florian Bidaud
2022-11-23
Hi,
There is an error in your code, you've added quotes around your variable name. This should work.
A = 300;
writematrix(A, 'A.txt')
destdirectory = 'C:\Users\....\FolderN';
movefile('A.txt', destdirectory);
Alternativeley, you can use writematrix to create and write into a txt file :
writematrix(A,fullfile(destdirectory,'A.txt'))
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!