フィルターのクリア

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

1 回表示 (過去 30 日間)
ErikaZ
ErikaZ 2019 年 3 月 1 日
回答済み: Walter Roberson 2019 年 3 月 1 日
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 件のコメント
ErikaZ
ErikaZ 2019 年 3 月 1 日
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

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 1 日
else j==3
is the same as
else
disp(j==3)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by