I made a correction of the location of the for t=1:10 loop. I stil have a logical output but ONLY ONE time.
for j = 2:3
%for t= 1:10
if j==2 % Stairs up
for t=1:10
for tt=1:2
if length(gait_events{j}{1,t})==3 && length(gait_events{j}{5,t})==3 && strcmp(side,'Left') % Left leg analyzed, starts with Left Leg
switch tt
case 1
idx_50TT{j}(t,tt)= round((gait_events{j}{3,t}(1,1) + gait_events{j}{7,t}(1,1))/2*fs);
case 2
idx_50TT{j}(t,tt)= round((gait_events{j}{3,t}(end,1) + gait_events{j}{2,t}(end,1))/2*fs);
end
elseif length(gait_events{j}{1,t})==3 && length(gait_events{j}{5,t})==3 && strcmp(side,'Right') % Right leg analyzed, starts with Right Leg
switch tt
case 1
idx_50TT{j}(t,tt)= round((gait_events{j}{3,t}(1,1) + gait_events{j}{7,t}(1,1))/2*fs);
case 2
idx_50TT{j}(t,tt)= round((gait_events{j}{7,t}(end,1) + gait_events{j}{6,t}(end,1))/2*fs);
end
else
disp('Not a LL or RR subject');
end
end
end
else j==3 % Stairs down
for t=1:10
for tt=1:2
if length(gait_events{j}{1,t})==3 && length(gait_events{j}{5,t})==3 && strcmp(side,'Left') %Left leg analyzed, starts with Left Leg
switch tt
case 1
idx_50TT{j}(t,tt)= round((gait_events{j}{8,t}(1,1) + gait_events{j}{5,t}(1,1))/2*fs);
case 2
idx_50TT{j}(t,tt)= round((gait_events{j}{3,t}(2,1) + gait_events{j}{1,t}(end,1))/2*fs);
end
elseif length(gait_events{j}{1,t})==3 && length(gait_events{j}{5,t})==3 && strcmp(side,'Right') % Right leg analyzed, starts with Right Leg
switch tt
case 1
idx_50TT{j}(t,tt)= round((gait_events{j}{4,t}(1,1) + gait_events{j}{1,t}(1,1))/2*fs);
case 2
idx_50TT{j}(t,tt)= round((gait_events{j}{7,t}(2,1) + gait_events{j}{5,t}(end,1))/2*fs);
end
else
disp('Not a LL or RR subject');
end
end
end
end
%end
end