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');

采纳的回答

Florian Bidaud
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 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by