How to import files from an outside folder?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!