Filter löschen
Filter löschen

How to import files from an outside folder?

5 Ansichten (letzte 30 Tage)
ARP
ARP am 30 Apr. 2018
Beantwortet: Fangjun Jiang am 30 Apr. 2018
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) ;

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 30 Apr. 2018
A = import_AB_function(fullfile(folder,files(i).name))

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by