saving for loop data

1 回表示 (過去 30 日間)
David Togonidze
David Togonidze 2021 年 10 月 27 日
回答済み: Abhishek Kolla 2021 年 11 月 10 日
guys I have several for loops to generate some angles for me. At the end I sort it out with If statement. I want to store all angles that are true for the if statement. This only gives me the one combination. I want all of them. keep in mind that Thetas (theta1-theta5) can be negative also.
if firstply_F <= 1 & secondply_F <= 1 & thirdply_F <= 1 & fourthply_F <= 1 & fifthply_F <=1 firstply_Fth <= 1 & secondply_Fth <= 1 & thirdply_Fth <= 1 & fourhtply_Fth <= 1 & fifthply_Fth <= 1
z=[theta1 firstply_F];
end

採用された回答

Abhishek Kolla
Abhishek Kolla 2021 年 11 月 10 日
Hi David,
The above issue can be solved using nested if statements so that even if single condition check fail it will not perform the remaining conditional checks. The code snippet is as follows
if condition 1 <=1 && condition 2 <=1
if condition 3 <=1 && condition 4 <=1
%perform the operation required when all conditions are met
end
end

その他の回答 (0 件)

カテゴリ

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