Home > m > helper > ltpda_getmax.m

ltpda_getmax

PURPOSE ^

LTPDA_GETMAX get the index and value of the maximum value in an array.

SYNOPSIS ^

function [index, max] = ltpda_getmax(a)

DESCRIPTION ^

 LTPDA_GETMAX get the index and value of the maximum value in an array.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: LTPDA_GETMAX get the index and value of the maximum value in an array

 CALL:       [index, max] = ltpda_getmax(a)

 INPUTS:     a     - vector od double

 OUTPUTS:    index - index of the maximum
             max   - value of the maximum

 VERSION: $Id: ltpda_getmax.html,v 1.14 2008/03/31 10:27:31 hewitson Exp $

 HISTORY: 26-01-2007 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [index, max] = ltpda_getmax(a)
0002 % LTPDA_GETMAX get the index and value of the maximum value in an array.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: LTPDA_GETMAX get the index and value of the maximum value in an array
0007 %
0008 % CALL:       [index, max] = ltpda_getmax(a)
0009 %
0010 % INPUTS:     a     - vector od double
0011 %
0012 % OUTPUTS:    index - index of the maximum
0013 %             max   - value of the maximum
0014 %
0015 % VERSION: $Id: ltpda_getmax.html,v 1.14 2008/03/31 10:27:31 hewitson Exp $
0016 %
0017 % HISTORY: 26-01-2007 M Hewitson
0018 %             Creation
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 max = a(1);
0023 index = 1;
0024 
0025 for k=1:length(a)
0026   if(a(k) > max)
0027     max = a(k);
0028     index = k;
0029   end
0030 end
0031 
0032 
0033 % END

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003