Reading data from different data files
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
Hello, I need some help importing data files. I'm running some simulations, which result in simple files with 3 columns. Nothing new so far. However, I do not have the same amount of data files for each variable. To make things clear: Let's say I have to following data files: Fx_1_1_1 Fx_1_1_2 Fx_1_1_3 Fx_1_1_4 Fx_1_1_5 Fx_1_1_6 Fx_1_1_7 Fx_1_1_8 Fx_1_2_1 Fx_1_2_2 Fx_1_2_3 Fx_1_2_4 Fx_1_2_5 Fx_2_1_1 Fx_2_1_2 Fx_2_1_3 Fx_2_1_4 Fx_2_1_5 Fx_2_1_6 Fx_2_1_7 Fx_2_2_1 Fx_2_2_2 Fx_2_2_3 Fx_2_2_4 Fx_2_2_5 Fx_2_2_6
I'm using (as long as i had the same amount of data files for each place)
filepath = 'C:\...\...\...\Fx_';
for a=1:2
for b=1:2
for c=1:8
filename = strcat(strcat(strcat(strcat(strcat(filepath,int2str(a)),'_'),int2str(b)),'_'),int2str(c),'');
filedata = load(filename);
blabla doing something with the files;
end
end
end
Now I don't know how to change these lines so that I can import all files and do the analysis I need. Whenever I run the code and I don't have, for example Fx_1_2_6 it returns an error. Does anyone know how I can avoid this?
1 Kommentar
Vishal Rane
am 30 Nov. 2012
Bearbeitet: Vishal Rane
am 30 Nov. 2012
What do the three numbers in the file name represent ?
Also you can reduce the file name construction command to this :
filename = [ filepath, int2str(a), '_', int2str(b), '_', intstr(c)];
Antworten (1)
dpb
am 30 Nov. 2012
Use dir() w/ appropriate wild card for the subset of names desired then process the resulting list...
d=dir('Fx_1_*');
for f={d.name}
x=load(f);
% process
end
You can enclose the above in the req'd loops to build the wild card string as needed...
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!