Home > omviz > 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<min(jd(:)) | jd1>max(jd(:))),
0024    disp(' outside range')
0025    return
0026   end
0027 end
0028 if(nargin==3),
0029  i=find(jd>=jd1&jd<=jd2);
0030 else
0031  i=near(jd,jd1,1);
0032 end
0033

Generated on Thu 01-Dec-2005 08:50:35 by m2html © 2003