Very basic problem with using isAlways

4 views (last 30 days)
I'm trying to learn to use the symbolic math functionality and I was playing around with isAlways. I ran the following commands: a=sym('a','real'); b=sym('b','real');
isAlways(a>b|a==b|a<b)
ans=1
isAlways(a>=b|a<b)
ans=1
isAlways(a>=b|a<=b)
ans=0
I'm not entirely sure what I'm doing wrong but I really did expect the last statement to be true as well. Any thoughts?
Thanks a lot!

Accepted Answer

Geoff Hayes
Geoff Hayes on 25 Jul 2014
It could be that isAlways can't determine the validity of the inequalities. From isAlways, check the validity of this inequality. When isAlways cannot determine whether the condition is valid, it returns logical 0 by default. (See their example for this.)
Also from the same link, to change this default behavior, use Unknown. For example, specify that isAlways must return logical 1 if it cannot determine the validity of this inequality...Instead of true, you can also specify error. In this case, isAlways will throw an error if it cannot determine the validity of the condition.
Try the following
sAlways(a>=b|a<=b,'Unknown','error')
and observe the results. If an error is thrown, then the function can't determine the validity.
  2 Comments
Poachumsm
Poachumsm on 25 Jul 2014
Thank you! That turned out to be right - the function can't determine the validity. I don't know enough that understand the source of this error but I do get that for whatever reason isAlways doesn't work in this case.
Roger Stafford
Roger Stafford on 25 Jul 2014
I would consider that result an actual bug. The 'isAlways' function seems to be handling the '|' symbol as if it were the exclusive OR (xor) rather than the inclusive kind (or). I would advise you to send this result to Mathworks' support personnel for a possible revision.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!