Help With IF AND statement

조회 수: 2 (최근 30일)
John hope
John hope 2019년 3월 6일
댓글: John hope 2019년 3월 6일
Hi all
I am trying to code the following statement:-
"If Radius is between 500-600 AND Ton is greater than 58 then do the following..."
I have coded this as:-
if ((Radius >= 500) && (Radius <= 600)) & Ton > 58
But this doesnt work i get an output stating ans = logical 0.
Any ideas.
Thank you
  댓글 수: 3
Walter Roberson
Walter Roberson 2019년 3월 6일
If you are using a radius or Ton value right near the boundary, for debugging, subtract the boundary from the actual value: the result might show you a small difference between the boundary and the actual value.
For example,
Radius = 500*(1-eps)
This will display as 500, but it is less than 500, and Radius - 500 would show the numeric difference.
John hope
John hope 2019년 3월 6일
Thaks Stephen
Got it to work, nothng wrong with the code i was messing up else where in the code which was why i was having issues,
Thank you.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by