Loading many .txt files by title in matlab

조회 수: 1 (최근 30일)
Marek Rousek
Marek Rousek 2015년 12월 9일
편집: Stephen23 2019년 6월 19일
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에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by