text file to be in the folder
Show older comments
if i run the code i create the folder and the text file is created in it but text are not displayed in the text file. i tried with pwd also but it didnot work
Answers (1)
Karim
on 14 Jul 2022
No need for the save command, first create the folder (or check that it exists) and then you can write the file directly into the folder. See below for the steps
% first create folder
t = now;
folder1 = ['SCREW' datestr(t, 'yyyymmdd')];
if isfolder(folder1)
delete([folder1, '\*'])
else
mkdir(folder1)
end
% now create the file and its contents
label_1 = '# Screw';
fid = fopen(fullfile(folder1, 'screw size.txt'),'wt');
fprintf(fid,'%s\n', label_1);
fclose(fid);
Categories
Find more on Standard File Formats 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!