reshaping 2 vectors of dates

조회 수: 2 (최근 30일)
antonet
antonet 2012년 7월 9일
Hi everyone
I have the following cell vector of dates
D={'September-October 2000' ...
'November-December 2000' ...
'January-Febraury 2001'...
'March-April 2001'...
'May-June 2001'};
Is there any way to change it to
D={'SO 2000' ...
'ND 2000' ...
'JF 2001'...
'MA 2001'...
'MJ 2001'};
Where as you can see I use only the first letter from each pair of months
The second cell vector of dates is the following
DD={ '4 Weeks Ending 24.09.00'...
'4 Weeks Ending 22.10.00'...
'4 Weeks Ending 19.11.00'...
'4 Weeks Ending 17.12.00'...
'4 Weeks Ending 14.01.01'...
'4 Weeks Ending 11.02.01'};
Is there a way to change it to
DD={ '4W240900'...
'4W221000'...
'4W191100'...
'4W171200'...
'4W140101'...
'4W110201'};
Where as you can see I merge number 4 with the first letter of the word ‘Weaks’ and the dates from which I omit the dot
cheers
  댓글 수: 5
antonet
antonet 2012년 7월 9일
편집: antonet 2012년 7월 9일
Ok! now. thank you
antonet
antonet 2012년 7월 10일
could anyone help? Thanks alot

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 7월 10일
편집: Andrei Bobrov 2012년 7월 10일
variant use within regexprep
D = regexprep(D,'[a-z\-]','');
DD = regexprep(DD,'[ .a-zE]','');
  댓글 수: 5
antonet
antonet 2012년 7월 10일
wOw. YOU ARE THE BEST!
antonet
antonet 2012년 7월 10일
편집: antonet 2012년 7월 10일
just a small question. In case some dates are empty how can i modify these codes?
FOr instance
D={' ' ...
'November-December 2000' ...
'January-Febraury 2001'...
'March-April 2001'...
'May-June 2001'};
DD={' '...
'4 Weeks Ending 22.10.00'...
'4 Weeks Ending 19.11.00'...
'4 Weeks Ending 17.12.00'...
'4 Weeks Ending 14.01.01'...
'4 Weeks Ending 11.02.01'};

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

추가 답변 (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