I have a bunch of .mat files, each containing a specific variable that I would like to combine into one variable. Yes, I know this is not efficient coding, but in order to conserve memory I needed to save them this way. My main question is how to load each variable, when their names only differ by a number.
For example, my variables could be DataSet_1000_1_1, DataSet_1000_2_1, DataSet_1000_3_1, DataSet_1000_4_1, etc.
I have a lot of these variables, each saved in a different .mat file. I would like to avoid typing each name to combine them. This is what I've tried so far-
inJ0 = ;
for i = 1:length(Start)
inJ0temp = load(['F:\SuperComputerDataSets\DataSets_1000\DataSet_1000_' num2str(Start(i)) '_1'],['inJ0_1000_' num2str(Start(i)) '_1']);
inJ0 = [inJ0;inJ0temp];
In this example, J0temp is a structure with the variable I want. However, I would like to assign this variable a name that I can then use for other purposes, such as combining onto other arrays. I've tried using eval, but that doesn't seem to work. My problem is that I can't say
J0temp = J0temp.DataSet_1000_1_1;
because the number 1 would change on every loop iteration. Is there a way to do something like this?
J0temp = J0temp.DataSet_1000_num2str(Start(i))_1;
I've also tried evalin, but can't get that to work either. It's the num2str that seems to be messing me up, I just don't know how to incorporate that into other functions I guess. I've also tried using load without the J0temp assignment, but then I can't work with that variable.
load(['F:\SuperComputerDataSets\DataSets_1000\DataSet_1000_' num2str(Start(i)) '_1'],['inJ0_1000_' num2str(Start(i)) '_1']);
J0temp = ['inJ0_1000_' num2str(Start(i)) '_1'];
Any help is appreciated, thanks.