Click the box titles below to expand:

How to's

XSLT

GOOGLE MAPS API

PHP

Antelope

Perl

Document Object Model (DOM)

UNIX

Generic Mapping Tools (GMT)

Miscellaneous

Projects

Courses Taught

Latest Favorites

Mac OS X

Web Development

Beta

How To :: Antelope – Matlab tricks and tips

Converting between timestamps used by Antelope and Matlab

Antelope gives out epoch times as integer representations from Jan 01, 1970. Matlab does not like those, and prefers serial numbers (time in days since Jan 01 0000). Don't ask my why....

  1. First retrieve the epoch time that you are interested in:
  2. this_time= dbgetv( dbpointer, 'time' ) ;
  3. Convert this to a string that Matlab can understand (aka a Date String):
  4. this_mextime = epoch2str( this_time, '%d-%b-%Y %H:%M:%s' ) ;
  5. Convert this to a Matlab happy value (aka serial time) using datenum, which likes only three very specific formats:
  6. this_serialtime = datenum( this_mextime, 0 ) ;

    More information: http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/datenum.html

  7. Add this to a matrix, where 'i' is the incrementing value increasing by one in every loop (ie. appending to the matrix):
  8. graph_x(i) = this_serialtime ;
  9. When it comes time to plot these values (graph_x is matrix with time stamps, graph_y is matrix with values):
  10. plot( graph_x, graph_y, 'Color','r', 'LineWidth', 2 ) ;
  11. The Matlab function datetick takes the serial timestamps, and converts them on the plot using a conversion integer. I used '26' which equates to:

    IntFormatExample
    26'yyyy/mm/dd'2000/03/01
    You can use any int value listed in the 'Date Format Number' table. Follow the link below.

    datetick( 'x',26,'keeplimits' ) ;

    More information: http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/datetick.html

This results in an x-axis scale like this, with real epoch times converted:

Data return rate graph for USArray TA station A04A