Home > SaliencyToolbox > clamp.m

clamp

PURPOSE ^

clamp - clamps data at the top and/or bottom.

SYNOPSIS ^

function data = clamp(data,bottom,top)

DESCRIPTION ^

 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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-2013
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,top)
0020 
0021 if ~isempty(bottom)
0022   data(data < bottom) = bottom;
0023 end
0024 
0025 if nargin >= 3
0026   data(data > top) = top;
0027 end

Generated on Thu 18-Jul-2013 06:10:46 by m2html © 2005