I agree with Jhon, more specific details could help understanding the problem..
But 1 possibility would be throwing an error if the input value is out of range, e.g. add to the beginning of the function:
Range = [100 150];
if input_val < min(Range) || input_val > max(Range)
error('input value out of range')
This will not allow the function to run with values you do not want to treat