source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/local_ext_mod/lmin_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.6 KB
Line 
1function [lmval,indd]=lmin_pw(xx, dx)
2%   Find  piece-wise local minima in vector XX,where
3%       LMVAL is the output vector with minima values, INDD  is the
4%       corresponding indexes, DX is scalar length of piece where minima 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=10; and dx=1000;
9%
10%   dx=150; xx=[0:0.01:35]'; y=sin(xx .* cos(xx /4.5)) + cos(xx);
11%   y(length(y))=-2; plot(xx,y); grid; hold on;
12%   %   Excluding first and last points
13%   [b,a]=lmin_pw(y,dx); plot(xx(a),y(a),'r+')
14%   % Way to include first and last points can be as:
15%   yy=[1.5; y; 0];         % padd with values higher than end values
16%   [b,a]=lmin_pw(yy,dx); a=a-1; plot(xx(a),y(a),'go')
17%
18%       see also LMIN,LMAX, LMAX_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(end)];
29nn=floor(len_x/dx);
30ncount=1; lmval=[]; indd=[];
31for ii=1:nn,
32    [lm,ind] = min(xx(ncount: ii*dx+1)) ;
33        ind=ind+(ii-1)*dx;
34         if (ind ~=ncount) & (ind~=ii*dx+1),   
35         lmval=[lmval, lm]; indd=[indd, ind];
36end     
37ncount=ncount +dx;
38end
39[lm,ind] = min(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); lmval=lmval(1:end-1);
46    end
47return
Note: See TracBrowser for help on using the repository browser.