MATLAB: How to produce an output of 0 when the input code is CheckStatus(0,1) using logical operators

andlogical operators

The purpose is: Assign onTime with true if noTraffic is true and gasEmpty is false.
As of right now, my code is:
function onTime = CheckStatus(noTraffic, gasEmpty)
% Assign onTime with true if noTraffic is true and gasEmpty is false
onTime = xor(noTraffic,gasEmpty);
end
This works for 3/4 of the tests, but I can't figure out how to make it pass for the 4th test. Can someone point me in the right direction please? Like do I add a logical operator in the actual onTime function? Or where would I add it?

Best Answer

Remember that xor(A,B) is true if A is true and B is false, but xor(A,B) is also true if A is false and B is true. You will need some kind of "and" rather than a form of "or"