필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by