Loading many .txt files by title in matlab
조회 수: 1 (최근 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
댓글 수: 0
답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!