![]() |
| Script date1.m | |||
|
|||
|
%we start from a string format
sa='01-Jan-2008 00:00:01' %its corresponding %single value format nv=datenum(sa) %numeric array format na=fix(datevec(nv)) % %the same day of the next year % % with a single value format nv1=addtodate(nv,1,'year') %with a string array format sa1=datestr(nv1) %with a numeric array format na1=datevec(sa1) % %we form an array with two rows %of the two previous numeric arrays two_na=[na;na1] %and of the two previous string arrays two_sa=[sa;sa1] % %the corresponding single value format % %using numeric arrays two_nv_n=datenum(two_na) %using string arrays two_nv_s=datenum(two_sa) % %their expected differences %2008 is a leap year diff_n=two_nv_n(2)-two_nv_n(1) diff_s=two_nv_s(2)-two_nv_s(1) |
|||
| Back | |||