Very basic problem with using isAlways

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!

 採用された回答

Geoff Hayes
Geoff Hayes 2014 年 7 月 25 日

0 投票

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 件のコメント

Poachumsm
Poachumsm 2014 年 7 月 25 日
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 2014 年 7 月 25 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by