Loading many .txt files by title in matlab

4 次查看(过去 30 天)
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

回答(2 个)

Walter Roberson
Walter Roberson 2015-12-9

Stephen23
Stephen23 2015-12-9
编辑:Stephen23 2019-6-19
  1 个评论
Marek Rousek
Marek Rousek 2015-12-9
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 ...

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by