Find commontimes

Finds common date-times from two or more date-time vectors with a given tolerance in seconds
191 Downloads
Updated Thu, 06 Jun 2013 20:40:58 +0000

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

Cite As

M Sohrabinia (2024). Find commontimes (https://www.mathworks.com/matlabcentral/fileexchange/42118-find-commontimes), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Dates and Time in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0