summaryrefslogtreecommitdiff
path: root/check_bound.m
blob: 8f14094e81d25d2a35cfe9cd21858b0dd121f9b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function [x,adjusted]=check_bound(x,xleft,xright)
% check if number out of bound and then assign it to the mid of the region
if xleft > xright
    % sanity check for bounds
    tmp=xright;
    xright=xleft;
    xleft=tmp;
end
if x<xleft || x>xright
    x=(xleft+xright)/2;
    adjusted = true;
else
    adjusted = false;
end