Hi! How I can write condition "If, else if" for repeated value of variable ?

2 ビュー (過去 30 日間)
Aknur
Aknur 2023 年 4 月 24 日
コメント済み: Aknur 2023 年 4 月 28 日
Hello! Kindly ask about variables and condition. I have two variables plane00, and plane01. In some cases they can be parallel, and if plane01 equal to 6 second time then statement will be another
How I can write condition if for repeated value of variable
plane01 equal to 6 second time, then calculate Phi = 180 - Phi0;
Before I use condidition if plane00 and plane01 are parallel each other, and if plane01 again == 6, then statement will another
I used this one
elseif all(ismember([plane00, plane01], parallel_planes(3,:)))
disp('Parallel 3rd row 5 and 6 plane');
PhiBar = -(180 + Phi0); %last
ThetaBar = (90 - Theta0);
Thank you in advance for your time and any advice
Best regards, Aknur

採用された回答

Sivapriya Srinivasan
Sivapriya Srinivasan 2023 年 4 月 25 日
Hello Aknur,
You can modify the code to modify the exiting elseif statement to include an additional check
if all(ismember([plane00, plane01], parallel_planes(3,:)))
if plane01 == 6
% calculate Phi as 180 - Phi0
Phi = 180 - Phi0;
disp('Parallel 3rd row 5 and 6 plane with plane01 = 6 seconds');
else
% calculate PhiBar as -(180 + Phi0)
PhiBar = -(180 + Phi0);
ThetaBar = 90 - Theta0;
disp('Parallel 3rd row 5 and 6 plane');
end
end
if statement checks if both plane00 and plane01 are parallel to the third row of the parallel_planes matrix
if plane01 equals to 6seonds then code calculates phi as 190minus phi0
if not then phiBar as –(180+phi0) and thetaBar as 90-theta0
finally code displays a message indicating whether plane01 was equal tro 6seconds or not
You may need to modify the code depending on your specific use case
Hope this helps!
  1 件のコメント
Aknur
Aknur 2023 年 4 月 28 日
Thank you for your help. Yes it works for only one time.
My question was how to make that if plane01 == 6 second time, like in first iteration if plane01 == 6 % calculate Phi as 180 - Phi0 , but if plane01 == 6 again then accept Phi0 as another value of Phi0 (Phi(ii-1)) which were before

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by