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개)

카테고리

질문:

2014년 7월 25일

댓글:

2014년 7월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by