Hi everyone!
I have a little problem with the following code, where I first create a structure with the variables I want to use and then later on fill them with a loop. When I fill the variables in the structure with the data from csv_data, the variable-names are overwritten or the structure changes?! I don't really understand what or why this is happening, because working with structures is new to me (and I'm not really a Matlab-Pro to begin with).
Any way I can avoid this problem?
I simplified the code a bit, so you can recreate the problem. Check the struct before and after filling with the loop! Before is how I want it to be (but ultimately filled with data of course!).
csv_data = randn([300 5]);csv_variables = struct('var',struct('lat', [], 'lon', [], 'A', [], 'B', [], 'C', []));for i = 1:5; csv_variables(i).var = csv_data(:,i);end
Best Answer