diff options
Diffstat (limited to 'check_bound.m')
-rw-r--r-- | check_bound.m | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/check_bound.m b/check_bound.m new file mode 100644 index 0000000..8f14094 --- /dev/null +++ b/check_bound.m @@ -0,0 +1,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 + |