Loop for classifying variables is not working??????

if x(1) > 31.5 && x(1) < 36.5
if x(2) >= 60
if x(3) >= 2
disp('Successful Kick has been made')
else
disp('Kick was unsuccessful')
end
end
end
I am using code that finds new values of x per each time step and it is simulating a kick. x(1) is the x axis, x(2) is the y axis and x(3) is the z axis. This code is meant to classify if the kick is successful or not. The goal posts are at 31.5 and 36.5 on the x axis, in the y these posts are at 60, and there is a crossbar at 2 where the ball needs to cross. The code however will not do it for any number past 32!!!!!!!!!!!!! HELP

1 件のコメント

Ameer Hamza
Ameer Hamza 2018 年 5 月 4 日
What is not working in this code? What is the input you are giving to the code?

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

回答 (1 件)

Jan
Jan 2018 年 5 月 4 日
編集済み: Jan 2018 年 5 月 4 日

1 投票

If you want an output in every case, combine the if conditions:
if x(1) > 31.5 && x(1) < 36.5 && x(2) >= 60 && x(3) >= 2
disp('Successful Kick has been made')
else
disp('Kick was unsuccessful')
end
I do not see any other problem. Please explain "will not do" with any details. Provide an input, for which you think the code fails.

カテゴリ

ヘルプ センター および File Exchange で Debugging and Improving Code についてさらに検索

質問済み:

2018 年 5 月 4 日

編集済み:

Jan
2018 年 5 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by