I currently have a function that performs some calcuations for me based on a folder and now that I also have data in other folders, I am writting a new script to go through all these folders. The way I wrote my code at first does not allow me to store results when running a loop, so I decided to write the script to do so, so I don't have to write a new function.
Suppose I have several arrays called array1,array2,....,arrayN and need to assign those to a nested structure, whose 'nestedStruct' and 'Field' names also vary. As an example, I need to have as output
Case.Speed1.Location1.array1 = [....]
Case.Speed1.Location2.array1 = [....]
Case.SpeedN.LocationN.arrayN = [....]
And so it goes, for different values of N. The 'Case' is easy to change using a if and a strcmp, but the rest I could not succeed. I tried doing the following (note that I wrote only 2 arrays in the example to make things shorter):
[Case,Speed,Location,Array1,Array2,...ArrayN] = function(....)
Case = struct(['Speed' num2str(Speed)],struct(['Location' num2str(Location)], struct ('name_of_array1',Array1,'name_of_array_2',Array2)))
But the output is being rewritten and nothing is stored in different nested structure or field. What can I do?
Thanks in advance