source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/local_ext_mod/lmax_pw.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.7 KB
Line 
1function [lmval,indd]=lmax_pw(xx, dx)
2%   Find  piece-wise  local maxima in vector XX,where
3%       LMVAL is the output vector with maxima values, INDD  is the
4%       corresponding indexes, DX is length of piece where maxima is searched,
5%   IMPORTANT:      FIRST and LAST point in vector are excluded
6%   IMPORTANT:      XX must be single column vector
7%   IMPORTANT:      Length of DX must be very carefully selected
8%       For example compare dx=30; and dx=1000;
9%
10%   dx=150; xx=[0:0.01:35]'; y=sin(xx .* cos(xx /4.5)) + cos(xx);
11%    plot(xx,y); grid; hold on;
12%   %   Excluding first and last points
13%   [b,a]=lmax_pw(y,dx); plot(xx(a),y(a),'r+')
14%   % Way to include first and last points can be as:
15%   y(1)=1.5; yy=[0; y; -1;];   % padd with smaller values
16%   [b,a]=lmax_pw(yy,dx); a=a-1; plot(xx(a),y(a),'go')
17%
18%       see also LMIN, LMAX,  LMIN_PW, MATCH
19
20%       Sergei Koptenko, Applied Acoustic Technologies, Toronto, Canada
21%   sergei.koptenko@sympatico.ca,  March/11/2003 
22
23if nargin <2,
24        disp('Not enough arguments'); return
25end
26
27len_x = length(xx);
28xx = [xx; xx(len_x); xx(len_x)];
29nn=floor(len_x/dx);
30ncount=1; lmval=[]; indd=[];
31        for ii=1:nn,
32        [lm,ind] = max(xx(ncount: ii*dx+2)) ;
33        ind=ind+(ii-1)*dx;
34                 if (ind ~=ncount) & (ind~=ii*dx+2),   
35                    lmval=[lmval, lm]; indd=[indd, ind];
36                end     
37        ncount=ncount +dx;
38        end
39[lm,ind] = max(xx(ii*dx:len_x));
40        if (ind ~=len_x) & (ind~=ii*dx),   
41            lmval=[lmval, lm]; indd=[indd, (ind+ii*dx-1)];
42        end
43   
44       if indd(end)==len_x, 
45           indd=  indd(1:end-1);
46           lmval=lmval(1:end-1);   
47       end
48return
Note: See TracBrowser for help on using the repository browser.