How can I send text-files to a specific folders?

2 次查看(过去 30 天)
What lines of code would be useful to send .txt files to different and specific folders?
Here is my path.
H:\wall_location_dataset\ExtractVolume_01\avg DATA
My intentions is to send the 4 text files to avg DATA instead of ExtractVolume_01.
Here is a section of code of what I have for a set of codes. This part of the program allows the loop to assign a number to a text file (avg+j+.txt, ex. avg1.txt) and record slope and two y-intercepts. What approach should I use to specify the path to a folder (send to avg DATA) and allow the loop (for j=1:4) to assign the numbers to the textfile (avg[1,2,3, OR 4].txt?
fileOutput=sprintf('avg%01d.txt',j);
fileOut= fopen(fileOutput,'wt');
fprintf(fileOut,'Data avg results \r\n');
fprintf(fileOut,'avg%0.0f\r\n',j);
fprintf(fileOut,'Data order (1-2): Slope , Y-int (xy1), Y-int (xy2) \r\n');
fprintf(fileOut,'Slope= %0.4f\r\n',m);
fprintf(fileOut,'Y-int(x1y1)= %0.4f\r\n', Bxy1);
fprintf(fileOut,'Y-int(x2y2)= %0.4f\r\n', Bxy2);
fclose(fileOut);

采纳的回答

Walter Roberson
Walter Roberson 2017-7-26
outdir = 'avg Data'; %you can fully qualify the directory name
fileOutput = fullfile( outdir, sprintf('avg%01d.txt',j) );

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Low-Level File I/O 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by