Reputation: 1
I am new to Matlab, stuck with understanding data types(especially cell), probably there is an elegant solution I do not know about.
I have a cell which contains other cells with dates:
30/09/2005
30/12/2005
...
30/09/2016
I have also a cell with cells containing corresponding values:
1
5
...
3
I want to interpolate those values for all days/ or working days( better for me). What I have been thinking to do is:
Seemed a good plan but function
datenum('30/12/2005') = 13297
datenum('30/09/2016') = 13217
gives numbers which can not be used as earlier date is bigger than later one.
Upvotes: 0
Views: 55
Reputation: 1122
You can add any number of days to a datetime.
t = datetime('now') + days(1);
In addition it can give you the amount of days of a duration. Hence:
t0 = datetime('30/09/2005');
tEnd = datetime('30/09/2016');
durationInDays = days(tEnd - t0);
myDates(0) = t0;
for i = 2:durationInDays
myDates(i) = myDates(i-1) + days(1);
end
Upvotes: 0