A simple wrapper function for simple logical indexing (i.e '<', '>' and '==') INPUT data The data to test. A matrix or a vector. test The value to be tested for using comparision comparision A string specifying the comparision / test to perform assign The value to assign if the test is true OUTPUT data The modified input, with logical matches of test to data using comaprsion replaced with assign. USAGE This funciton is not really intended for wide-scale usage. It is here only for use with mrg_dfsu_apply AUTHORS Daniel Pritchard LICENCE Code distributed as part of the MRG toolbox from the Marine Research Group at Queens Univeristy Belfast (QUB) School of Planning Architecture and Civil Engineering (SPACE). Distributed under a creative commons CC BY-SA licence, retaining full copyright of the original authors. http://creativecommons.org/licenses/by-sa/3.0/ http://www.qub.ac.uk/space/ http://www.qub.ac.uk/research-centres/eerc/ DEVELOPMENT v 1.0 July 2013 Initial attempt. Documentation. DP. %
0001 function data = mrg_assign(data, test, comparision, assign) 0002 % A simple wrapper function for simple logical indexing (i.e '<', '>' and '==') 0003 % 0004 % INPUT 0005 % data The data to test. A matrix or a vector. 0006 % test The value to be tested for using comparision 0007 % comparision A string specifying the comparision / test to perform 0008 % assign The value to assign if the test is true 0009 % 0010 % OUTPUT 0011 % data The modified input, with logical matches of test to data using 0012 % comaprsion replaced with assign. 0013 % 0014 % USAGE 0015 % This funciton is not really intended for wide-scale usage. It is here 0016 % only for use with mrg_dfsu_apply 0017 % 0018 % AUTHORS 0019 % Daniel Pritchard 0020 % 0021 % LICENCE 0022 % Code distributed as part of the MRG toolbox from the Marine Research 0023 % Group at Queens Univeristy Belfast (QUB) School of Planning 0024 % Architecture and Civil Engineering (SPACE). Distributed under a 0025 % creative commons CC BY-SA licence, retaining full copyright of the 0026 % original authors. 0027 % 0028 % http://creativecommons.org/licenses/by-sa/3.0/ 0029 % http://www.qub.ac.uk/space/ 0030 % http://www.qub.ac.uk/research-centres/eerc/ 0031 % 0032 % DEVELOPMENT 0033 % v 1.0 July 2013 0034 % Initial attempt. Documentation. DP. 0035 %% 0036 if test =='<' 0037 data(data<comparision)=assign; 0038 elseif test == '>' 0039 data(data>comparision)=assign; 0040 elseif test == '=' 0041 data(data==comparision)=assign; 0042 else 0043 error('Function only supports ">", "<", or "=", tests') 0044 end 0045 end