user3336190
user3336190

Reputation: 233

How to check sign of one value with in the range [a b]

I want to check sign of one value within the range by the following rule:

x=1 if x within the [a,b]
x=-1 otherwise

So I implemented by matlab code:

 (sign(x-a)+sign(b-x))./2

But my function is not correct. How to make correctly function of my problem?Thank you so much

Upvotes: 1

Views: 69

Answers (1)

hivert
hivert

Reputation: 10667

Do you mean sign(x-a)*sign(b-x) ?

Upvotes: 2

Related Questions