Hello, why Matlab does not check for second condition and give an answer without checking second condition after AND short circuit operator?
Show older comments
Hello everyone!
Kindly ask help in if statement. If I want to write..
if plane00 ==plane1 OR plane00==plane3 AND plane01==plane1 OR plane01==plane3, then print ('Planes are parallel1')
when I test the code below it only check for one condition isequal(plane00, plane1) || isequal(plane00, plane3)) and then supposed is true if it is true, but did not check second condition after && operator
(isequal(plane01,plane1))||isequal(plane01,plane3)
Thnak you in advance for your time and consideration. Apreciate any help
if (isequal(plane00, plane1) || isequal(plane00, plane3)) && ((isequal(plane01,plane1))||isequal(plane01,plane3))
fprintf('Planes are parallel1:');
ThetaBar = -(Theta0);
PhiBar = -(Phi0);
fprintf('ThetaBar: %f\n',ThetaBar);
fprintf('PhiBar: %f\n',PhiBar);
% I also tried to do smth like this
%(plane01 == 1 || 3 && plane00 == 1 || 3)
1 Comment
Walter Roberson
on 11 Apr 2023
Despite your "supposed is true", (isequal(plane00, plane1) || isequal(plane00, plane3)) is probably false.
For debugging, break it into two pieces:
part1 = isequal(plane00, plane1) || isequal(plane00, plane3);
disp(part1)
if part1 && ((isequal(plane01,plane1))||isequal(plane01,plane3))
Accepted Answer
More Answers (0)
Categories
Find more on Aerospace Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!