File Exchange

image thumbnail

Find commontimes

version 1.0.0.0 (2.66 KB) by M Sohrabinia
Finds common date-times from two or more date-time vectors with a given tolerance in seconds

0 Downloads

Updated 06 Jun 2013

View License

This function is useful when two or more datasets with different time
periods are available, and the goal is to compare only the common records
which are available in all datasets. It needs AT LEAST 2 date vectors and
finds common times in those two (or more) vectors. Each time in times1
will be matched with all times in times2 vector with a tolerance given in
prec_sec (precision in seconds). The default value for prec_sec is 5
seconds. Additional time vectors can be given (handled by varargin).
If any time does not exist even in one dataset, it will be ignored in the output.

Inputs:
times1: first times vector numeric or string format
times2: 2nd times vector numeric or string format
prec_sec: precision level in comparing times in seconds
varargin: 1 to n additional time vectors
Outputs:
commontimes: string vector of common times in all input time vectors.
idxs: original indexes of matched records from all input time vectors;
this can be used to re-organize other data-fields of datasets based on
the corresponding time vectors of each dataset. For example, if first
timeVec is from dataset1, the first column in idxs matrix will be the
original indexes of matched records in dataset1. Similarly, the
second, 3rd, ... columns of idxs can be used to extract common records
of dataset 2, 3, ... .
dtAll: a matrix of all input time vectors in Matlab's numeric date
format (can be used to validate the results).
cmntNum: common times in Matlab's numerical date format

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux