Hi! How I can write condition "If, else if" for repeated value of variable ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aknur
el 24 de Abr. de 2023
Comentada: Aknur
el 28 de Abr. de 2023
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
0 comentarios
Respuesta aceptada
Sivapriya Srinivasan
el 25 de Abr. de 2023
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!
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!