Effacer les filtres
Effacer les filtres

Why command window outputs 10 times ans = logical 1? See my separate comment, too

1 vue (au cours des 30 derniers jours)
I cannot find where am I missing the semicolon in the following code:
for j = 2:3
for t= 1:10
if j ==2 % Stairs up
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
else j==3 % Stairs down
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
The code is running properly but I am getting 10 of:
ans =
logical
1
in the command window. This is the first time I use switch. Is that causing it? how do I fix the code so I don't get the logical answers.
Thanks!
  1 commentaire
ErikaZ
ErikaZ le 1 Mar 2019
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

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 1 Mar 2019
else j==3
is the same as
else
disp(j==3)

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by