LTPDA_GETMAX get the index and value of the maximum value in an array function [index, max] = ltpda_getmax(a) M Hewitson 26-01-07 $Id: ltpda_getmax.html,v 1.1 2007/06/08 14:15:10 hewitson Exp $
0001 function [index, max] = ltpda_getmax(a) 0002 0003 % LTPDA_GETMAX get the index and value of the maximum 0004 % value in an array 0005 % 0006 % function [index, max] = ltpda_getmax(a) 0007 % 0008 % M Hewitson 26-01-07 0009 % 0010 % $Id: ltpda_getmax.html,v 1.1 2007/06/08 14:15:10 hewitson Exp $ 0011 % 0012 0013 0014 max = a(1); 0015 index = 1; 0016 0017 for k=1:length(a) 0018 if(a(k) > max) 0019 max = a(k); 0020 index = k; 0021 end 0022 end 0023 0024 0025 % END