can the conditions of if or while loop be negative float numbers?

1 view (last 30 days)
For example i want to execute
low_p can possibly contain a negative float number
if min(low_p)<-59.5
do something
end
but i am not able to do it . can anyone help me please
  1 Comment
Guillaume
Guillaume on 17 Dec 2014
A condition can be anything you want as long as it evaluates to true or false. You can of course compare negative numbers of any type.
Give us an example of something that doesn't work for you and we'll tell you why and how to fix it.
Your example works fine:
low_p = [-100.56 -20.455 pi 1452.266]; %for example
if min(low_p) < -59.5
disp('the minimum of low_p is less than -59.5')
else
disp('the minimum of low_p is more than -59.5')
end

Sign in to comment.

Answers (0)

Categories

Find more on Interactive Control and Callbacks 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!