Loading many .txt files by title in matlab

4 Ansichten (letzte 30 Tage)
Marek Rousek
Marek Rousek am 9 Dez. 2015
Bearbeitet: Stephen23 am 19 Jun. 2019
Hi, I need advice. In the following script, I for successive cycles for retrieving files by name. Each file is a series of numbers many that need to be loaded into the output matrix. I need to modify the code, I did not have eval in each line to manually enter the path to the file, but to create another transformation, where you enter the path to the appropriate folder for example. file = 'D: \ Matrix \ tomas-544-1a.avi_d' and for the rest of the cycle has been loaded. File entries are always the same names (matice_000 to matice_144) I just need to change the default folder, You do not know how to edit syntax ???
if true
for i=0:144
if i<10
eval(strcat('fileID = fopen(''D:\Matice\tomas-544-1a.avi_d\matice_00',num2str(i),'.txt'',''r'');'));
C = textscan(fileID,'%c');
textaky(:,i+1)=str2num(C{1});
elseif i<100
eval(strcat('fileID = fopen(''D:\Matice\tomas-544-1a.avi_d\matice_0',num2str(i),'.txt'',''r'');'));
C = textscan(fileID,'%c');
textaky(:,i+1)=str2num(C{1});
else
eval(strcat('fileID = fopen(''D:\Matice\tomas-544-1a.avi_d\matice_',num2str(i),'.txt'',''r'');'));
C = textscan(fileID,'%c');
textaky(:,i+1)=str2num(C{1});
end
end
end

Antworten (2)

Walter Roberson
Walter Roberson am 9 Dez. 2015

Stephen23
Stephen23 am 9 Dez. 2015
Bearbeitet: Stephen23 am 19 Jun. 2019
  1 Kommentar
Marek Rousek
Marek Rousek am 9 Dez. 2015
ok, thanks for the advice, I am really a beginner, but at the moment I have no other options of getting willed data from .txt. Therefore, I need advice, I can make a GUI where a person enters the path to the folder and the program no longer reads the data.
I think it is only a simple change to the program, but not to lose it ...

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by