MATLAB Answers

0

If block does not check conditions and do all of them at the same time

Asked by Mehrshad Abdollahpour on 10 Nov 2018
Latest activity Commented on by Mehrshad Abdollahpour on 12 Nov 2018
i using if block to solve a equation but the problem is when "0<u1<=0.0042" condition is not happen (X=0.0043) simulink acts like it happens and mathematical errors happen because of that.

  0 Comments

Sign in to comment.

Products

1 Answer

Answer by Walter Roberson
on 10 Nov 2018

0<u1<=0.0042 means ((0<u1)<=0.0042) . The first of those gives a result that is either 0 (false) or 1 (true) and that is then compared to 0.0042.
You need to use the general form A<u && u<=B

  7 Comments

look at the pic (for X=0.0043) , i done as you said and it shows the same error as "0<u1<0.0042" :
I notice that the block dialog talks about comma separated lists of expressions, but I do not know if they are and'd or or'd together
comma separator just make another elsif expression in if block.

Sign in to comment.