How to import files from an outside folder?
4 views (last 30 days)
Show older comments
I am stuck with the following. I am designing a GUI, which should access files from a different folder as the one where the GUI is located, that is the main matlab folder.
The GUI works fine when I place the files on the main folder, but fails when taking the files from outside folder. The data files are '.txt'. I made an import function that reads the files and separates the column values, as time and data. Only one time array is needed.
This is what I am trying:
folder = uigetdir('C:\Users\..\data folder');
files = dir(fullfile(folder, '*.txt'));
NF = length(files) ;
for i = 1:length(files)
A = import_AB_function(files(i).name) ;
data{i} = A;
Ampl_S {i} = (data{:, i}(:,end));
end
time = data{1, 1}(:,1);
Amplitudes_all = cell2mat(Ampl_S);
I can tell that import function is not able to interpret outside files from the main folder, but I can not see the way around it.
Any help please?
Thanks guys
%################################# Error output:
Error using textscan Invalid file identifier. Use fopen to generate a valid file identifier.
Error in import_AB_function (line 36) dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines', startRow(1)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
Error in please (line 22) A = import_AB_function(files(i).name) ;
0 Comments
Accepted Answer
More Answers (0)
See Also
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!