Loading many .txt files by title in matlab
1 view (last 30 days)
Show older comments
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 Comments
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!