I know I'm supposed to use vectorization instead of for loops, but I have to finish this assignement this way so I hope someone is willing to help me anyway.
This is my code:
names2 = {'soleus' 'tibant' 'gaslat' 'vaslat' 'rectfem' 'hamlat'};
Vars2 = {soleus, tibant, gaslat, vaslat, rectfem, hamlat};
nvars = length(Vars2);
for s = 1:1:nvars
for idx=1:10
P(idx).(names2{s}) = zeros(100,3);
end
end
for k = 1:3
for s = 1:1:nvars
for idx=1:10
P(idx).(names2{s})(:,k)= Vars2{s}.(motion{k})(:,1);
end
end
end
When I open P, it contains the same values for P(1).soleus, P(2).soleus, P(3).soleus, ...P(10).soleus,
while all of them should be different since they are data from different subjects.
'soleus' 'tibant' 'gaslat' 'vaslat' 'rectfem' 'hamlat' are structures containing 3 matrices: Gait(100x10), StairUp(100x10) and StairDown(100x10)
The number of colums (10) equals the number of subjects.