I have a large matrices with consistant number of rows. I wish to create a multidimensional struct with each row contained in its own dimension of the struct.
As I see it, I have two options.
1. Dynamically resize the struct each time:
for i = 1:size(data,1)
myStruct(i).data = data(i,:);
myStruct(i).data2 = data2(i,:);
myStruct(i).data3 = data3(i,:);
2. First convert the data into cells containing each row via num2cell and then creat the struct:
data = num2cell(data,2);
data2 = num2cell(data2,2);
data3 = num2cell(data3,2);
myStruct = struct('data',data,'data2',data2,'data3',data3)
I suppose my question is really about the efficiency of these two methods.
Which one of these two methods should run quicker over large data sets?
Is there a better way to convert matrices to a struct of this fashion that I have not thought of?
Thanks in advance!!