calculating the difference (in days) between successive dates

조회 수: 4 (최근 30일)
antonet
antonet 2012년 6월 6일
Dear all,
I have the following sequence of dates
dd={'2-11-2008' '30-11-2008' '28-12-2008' '25-01-2009' '22-02-2009' '22-03-2009' '19-04-2009' '17-05-2009' '14-06-2009}';
Is there any code that could calculate the difference (in days) between two successive dates in dd?
To be more specific, first the difference '30-11-2008'- '2-11-2008' Then the difference '28-12-2008' -'30-11-2008' Then '25-01-2009'-'28-12-2008' and so forth…. Probably a loop would be a good choice as dd contains many elements in my case
thanks
  댓글 수: 2
Oleg Komarov
Oleg Komarov 2012년 6월 6일
If you need for interp1() then you don't need to calculate the diff manually.
antonet
antonet 2012년 6월 6일
thanks oleg.!

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 6월 6일
dd={'2-11-2008' '30-11-2008' '28-12-2008' '25-01-2009' '22-02-2009' '22-03-2009' '19-04-2009' '17-05-2009' '14-06-2009'};
out = diff(datenum(dd,'dd-mm-yyyy'))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by