move txt file from one folder to another
2 views (last 30 days)
Show older comments
Alberto Acri
on 23 Nov 2022
Edited: Florian Bidaud
on 23 Nov 2022
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 Comments
Accepted Answer
Florian Bidaud
on 23 Nov 2022
Edited: Florian Bidaud
on 23 Nov 2022
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 Comments
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!