For loop with nested if loop

1 回表示 (過去 30 日間)
Aiden Sherry
Aiden Sherry 2021 年 3 月 1 日
編集済み: Matt J 2021 年 3 月 2 日
code is shown below:
drop_time =[];
for i = 1:height(HipVel)
if all(HipVel(i,1) > .0014)&all(KneeAngle < minAngle)
counter = [VJ_P1_T1.data(i,1)];
drop_time(:,1)= [counter];
end
end
disp(drop_time)
The drop time matrix is empty after running this loop. I want it to show the time in the data when hip velocity is above a certain value and the knee anlge is below a certain value.
Thanks!
  1 件のコメント
Matt J
Matt J 2021 年 3 月 1 日
編集済み: Matt J 2021 年 3 月 2 日
I want it to show the time in the data when hip velocity is above a certain value and the knee anlge is below a certain value.
If the result is empty, it likely means this condition is never satisfied in your data.

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

回答 (1 件)

Matt J
Matt J 2021 年 3 月 1 日
Perhaps this is what you want,
condition=( (HipVel > .0014) & (KneeAngle < minAngle);
drop_time = VJ_P1_T1.data( condition )
or
drop_time = VJ_P1_T1.data( find(condition,1) )

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by