I have 11 directories (-2d to 8d) each containing 7 data files (100mm.dat to 700mm.dat). At present in order to load these files in a single script I am doing the following:
load ./-2d/100mm.datload ./-2d/200mm.datload ./-2d/300mm.datload ./-2d/400mm.datload ./-2d/500mm.datload ./-2d/600mm.datload ./-2d/700mm.datm2d1 = X100mm;m2d2 = X200mm;m2d3 = X300mm;m2d4 = X400mm;m2d5 = X500mm;m2d6 = X600mm;m2d7 = X700mm;
for each directory. Now this works fine, it gets the data loaded up for me to play around with but my instinct tells me that there is a better way to write this and I was thinking that it may involve a for loop, something like:
for i=1:7; load ./-2d/(i)00mm.dat; m2d(i) = X(i)00mm;end
I know the above is probably nonsense to MATLAB but I am just trying to express the idea I have in my mind. Likewise for the directories would it be possible to use a for loop for that as well, something like:
for j=1:8; for i=1:7; load ./(j)d/(i)00mm.dat; m2d(i) = X(i)00mm; endend
Thanks in advance, I hope the above makes sense.
Best Answer