Finding the time difference between two vectors

Hello,
I have two time vectors (dd/mm/yyyy HH:MM:SS) of different sizes, [80x1] and [3x1]. The larger of the two the peak for an event. The smaller vector represent the full moon date for the 80 day period I have peak values for.
I have three different full moon dates in the 3x1 vector (e.g 28-Oct, 29-Nov, 30-Dec).
What I want to do create a new vector which has time value related to day around the closest full moon day (e.g. -1, 0, 1 2 3 etc)
Cheers
I am trying to convert

 采纳的回答

Let A (cell 80 x 1) and B(cell 3 x 1) your vectors
A1 = datenum(A);
B1 = datenum(B);
out = bsxfun(@minus,A1(:),B1(:).'); % out = A1(:) - B1(:).'; % in R2016b

1 个评论

Great that works really well! One last thing
Now I have a 80x3 matrix, how can I change that to a 80x1 matrix where I can choose the range of values from each column e.g from column 1, -2-28, column 2 0-28, column 3 - 0-28.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by