clamp - clamps data at the top and/or bottom. data = clamp(data,bottom,top) Sets all values of data that are less than bottom to bottom, and all values greater than top to top. data = clamp(data,bottom) Sets all values less than bottom to bottom. data = clamp(data,[],top) Sets all values greater than top to top.
0001 % clamp - clamps data at the top and/or bottom. 0002 % 0003 % data = clamp(data,bottom,top) 0004 % Sets all values of data that are less than bottom to bottom, 0005 % and all values greater than top to top. 0006 % 0007 % data = clamp(data,bottom) 0008 % Sets all values less than bottom to bottom. 0009 % 0010 % data = clamp(data,[],top) 0011 % Sets all values greater than top to top. 0012 0013 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2008 0014 % by Dirk B. Walther and the California Institute of Technology. 0015 % See the enclosed LICENSE.TXT document for the license agreement. 0016 % More information about this project is available at: 0017 % http://www.saliencytoolbox.net 0018 0019 function data = clamp(data,bottom,varargin) 0020 0021 if ~isempty(bottom) 0022 data(data < bottom) = bottom; 0023 end 0024 0025 if ~isempty(varargin) 0026 data(data > varargin{1}) = varargin{1}; 0027 end