When using writetable, I get the error "FILENAME must be a non-empty character vector or string scalar."
Show older comments
What I am trying to do is choose a folder with files in it that contain data, retrieve this data, and save it as a txt file. I am not having any problems with the data itself but rather, naming the text file I am saving the data to. Ideally, I would like to save the text file with the same name as the origional file but I am having trouble doing so. This issue only happens when I am processing more than one file.
I have been working on this issue for a long time and any help would be greatly appreciated.
Folder = uigetdir; % asks user for a folder
FilePattern = fullfile(Folder,'*deer*.dta'); % searches folder for .DTA files with DEER in the name
Files = dir(FilePattern); % puts files into struct array
for n=1:numel(Files)
File = struct2table(Files); % Takes the file name out of a struct and into a table
writetable(Deer_Trace_data{n},[ File{n,1} '.txt']); % names and saves file
end
Small point but currently, it also saves the filename including its previous extension which is .dta. Ideally, this would be removed but its not a big deal.
Please let me know if you need any more information.
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on String Parsing 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!