Load sequential numbered files in MatLab on the same script in different subfolders
2 views (last 30 days)
Let's imagine I have my MatLab script at the following address: "C:\Users\890384\Desktop\MatLab". Inside this, there are two folders: "Folder1" and "Folder2", for example. Inside of each of them there are, let's say, for simplicity, two different files, but they are called the same, array1.dat and array2.dat. Suppose these arrays are, in Folder1 and Folder2 the following:
% In Folder 1
array1_folder1=[1 2 3 4 5];
array2_folder1=[6 7 8 9 10];
% In Folder 2
array1_folder2=[6 7 8 9 10];
array2_folder2=[1 2 3 4 5];
Now, in the same path, " C:\Users\890384\Desktop\MatLab", I create a script to read these files and create two independent arrays (one for Folder1 and one for Folder 2). This will come in handy when you have, say, 200 files in each of these two folders with sequential numbered names. So this could easily be done for the individual case of, for example, Folder1:
As we can see, here I specify the sequencing of names in MyFolder. But how can I do the same, in the same script, to create mydata_folder2 at the same time, having two different MyFolders?
Thank you for your attention.