move txt file from one folder to another

6 ビュー (過去 30 日間)
Alberto Acri
Alberto Acri 2022 年 11 月 23 日
編集済み: Florian Bidaud 2022 年 11 月 23 日
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 Center および File ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by