How to reformat data from multiple files in a folder
Show older comments
I have written code to open a command window allowing the user to choose a folder. Then The files from this folder will be opened. I have this part of the code working. Now I need to include a code I had previously written to reformat the data in each file.
myFolder = uigetdir('C:\Users\c13459232\Documents\MATLAB');
if ~isdir(myFolder)
errorMessage = sprintf('Error: the following folder does not exist: \n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.asc');
Files = dir(filePattern);
for k = 1 : length(Files)
baseFileName = Files(k).name;
FileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', FileName);
This is the first section of the code I have written to open the files
Cell = textscan( FileName, '%d', 'delimiter', ';');
Data = cell2mat(Cell);
N = 1024;
Finish = reshape(Data, N, [])';
end
This code reformats the data the way I want it. I know I will need to write the code to create 50 new files (e.g. Finish_01, Finish_02, etc). I'm not sure how to compose this. Any tips would be greatly appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Environment and Settings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!