Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search


Matlab listing: maxr.m

function [xi,yi,hc] = maxr(a) 
%MAXR   Find interpolated maximizer(s) and max value(s) 
%       for (each column of) a.
%
%               [xi,yi,hc] = maxr(a) 
%
%  Calls max() followed by qint() for quadratic interpolation.
%  
   [m,n] = size(a); 
   if m==1, a=a'; t=m; m=n; n=t; end; 
   [y,x] = max(a); 
   xi=x;    % vector of maximizer locations, one per col of a
   yi=y;    % vector of maximum values, one per column of a
   if nargout>2, hc = zeros(1,n); end
   for j=1:n,   % loop over columns
     if x(j)>1, % only support interior maxima
       if x(j)<m, 
         [xdelta,yij,cj] = qint(a(x(j)-1,j),y(j),a(x(j)+1,j)); 
         xi(j) = x(j) + xdelta;
         if nargout>2, hc(j) = cj; end
         if (nargout>1), yi(j) = yij; end
       end; 
     end; 
   end;


Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

[How to cite this work]  [Order a printed hardcopy]  [Comment on this page via email]

``Spectral Audio Signal Processing'', by Julius O. Smith III, W3K Publishing, 2011, ISBN 978-0-9745607-3-1.
Copyright © 2016-07-18 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA