From: Luna Moon on
Hi all,

I am currently using some "for" loops in doing this and as I am
reviewing my programming, I don't like it myself.

So the question is how to align dates fast in Matlab.

The inputs are: ReferenceDates, MyDates, MyData, where "MyDates" and
"MyData" have the same number of rows, and "MyData" can be an array
with each row representing a data-point on that corresponding date.

The output are: MyDataAlignedAndFilled.

What does the function "MyAlignDatesAndFill" do?

It takes in the two sets of dates (in Matlab datenum format),

and get rid of all those dates that are in the "MyDates" set but not
in the "ReferenceDates" set, and discard the corresponding data point
on that date.

And also, it back-fills all those dates that are in "ReferenceDates"
but not in "MyDates", and fill the corresponding data points using the
data from previously available data.

For example,

ReferenceDates, MyDates, Data

6/19/2010 6/19/2010 5
6/20/2010 N/A 5
....


Here, because there is no data for 6/20/2010 in "MyDates", we fill it
using the previous data points that are available.

The output MyDataAlignedAndFilled has the same number of rows as
"ReferenceDates".

Any elegant way of doing this fast with no "for" loop?

Thanks a lot!
From: dpb on
Luna Moon wrote:
....

> and get rid of all those dates that are in the "MyDates" set but not
> in the "ReferenceDates" set, and discard the corresponding data point
> on that date.

doc ismember % and friends

> And also, it back-fills all those dates that are in "ReferenceDates"
> but not in "MyDates", and fill the corresponding data points using the
> data from previously available data.
....

doc interp1

--