Home > RPSstuff > tind.m

tind

PURPOSE ^

TIND finds index of Julian day array closest to the specified Gregorian time

SYNOPSIS ^

function i=tind(jd,greg,greg2);

DESCRIPTION ^

 TIND finds index of Julian day array closest to the specified Gregorian time
  if optional third argument, returns array of indices

   Usage: i=tind(jd,greg,[greg2]);
     
  examples:
    i=tind(jd,[1990 4 5 0 0 0]);
     returns the index of jd that is closest to to 0000 April 5, 1990 

    ii=tind(jd,[1990 4 5 0 0 0],[1992 3 1 12 0 0]);
   
    returns the indices of jd that are between 0000 April 5, 1990 
     and 1200 March 1, 1992.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function i=tind(jd,greg,greg2);
0002 % TIND finds index of Julian day array closest to the specified Gregorian time
0003 %  if optional third argument, returns array of indices
0004 %
0005 %   Usage: i=tind(jd,greg,[greg2]);
0006 %
0007 %  examples:
0008 %    i=tind(jd,[1990 4 5 0 0 0]);
0009 %     returns the index of jd that is closest to to 0000 April 5, 1990
0010 %
0011 %    ii=tind(jd,[1990 4 5 0 0 0],[1992 3 1 12 0 0]);
0012 %
0013 %    returns the indices of jd that are between 0000 April 5, 1990
0014 %     and 1200 March 1, 1992.
0015 %
0016 
0017 % Rich Signell (rsignell@usgs.gov)
0018 
0019 n=length(jd);
0020 jd1=julian(greg);
0021 if(nargin==3),
0022   jd2=julian(greg2);
0023   if(jd2<jd(1) | jd2>jd(n)),
0024    disp(' outside range')
0025    return
0026   end
0027 end
0028 if(jd1<jd(1) | jd1>jd(n)),
0029  disp(' outside range')
0030  return
0031 end
0032 if(nargin==3),
0033  i=find(jd>jd1&jd<jd2);
0034 else
0035  i=near(jd,jd1,1);
0036 end
0037

Generated on Wed 30-Nov-2005 14:45:02 by m2html © 2003