create a structure from a matrix
Afficher commentaires plus anciens
I have an nx2 matrix. The second column is meant to provide indexes into the first column: ex. please ignore the given x, it is there so the matrix below would look like I wanted it too.
x=[1;0.5]
0.5 1
0.75 1
1.0 1
1.25 1
0.2 2
0.4 2
0.6 2
0.15 3
0.3 3
0.45 3
I am trying to create a for loop to create a structure where each of the values in column 1 are put into its own structure based on the value in column 2. What I have so far:
trialdata=load(file);
numb=trialdata(:,2);
cell.numb=num2cell(MUnumb);
DTs=trialdata(:,1);
cell.DTs=num2cell(DTs);
DTs_per_numb=struct(field,trialdata);
fields='number';
for i={1:max(numb)};
DTs_per_numb.(fields{i})=cell.DTs(cell.numb==i);
end
I am getting the following error:
Cell contents reference from a non-cell array object.
Then need to iterate through each part of structure to run stats (ex. mean) Would appreciate any help. Thanks
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!