safeDivide - divides two arrays, checking for 0/0. result = safeDivide(arg1,arg2) returns arg1./arg2, where 0/0 is assumed to be 0 instead of NaN.
0001 % safeDivide - divides two arrays, checking for 0/0. 0002 % 0003 % result = safeDivide(arg1,arg2) 0004 % returns arg1./arg2, where 0/0 is assumed to be 0 instead of NaN. 0005 0006 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2007 0007 % by Dirk B. Walther and the California Institute of Technology. 0008 % See the enclosed LICENSE.TXT document for the license agreement. 0009 % More information about this project is available at: 0010 % http://www.saliencytoolbox.net 0011 0012 function result = safeDivide(arg1,arg2) 0013 0014 ze = (arg2 == 0); 0015 arg2(ze) = 1; 0016 result = arg1./arg2; 0017 result(ze) = 0;