필터 지우기
필터 지우기

filtering cell array table

조회 수: 4 (최근 30일)
AA
AA 2015년 10월 10일
댓글: AA 2015년 10월 10일
I want to filter the cell array column according to 'DD. mmmm YYYY' so I get only the dates. How can I do that? thanks
'Thu, Feb-14-13'
'Thu, Feb-07-13'
'Thu, Jan-31-13'
'Thu, Jan-24-13'
'Thu, Jan-17-13'
'Thu, Jan-10-13'
'Thu, Jan-03-13'
'Thu, Dec-27-12'
'Thu, Dec-20-12'
'Time'
'Time'
'Reg.'
'Reg.'
'UXS'
'CXX'
'UCC'
'USDC'
'USCCD'

채택된 답변

Walter Roberson
Walter Roberson 2015년 10월 10일
Why did you delete your earlier question? I was busy posting an answer to it and it disappeared out from under me :(
Good thing I saved the answer:
matchresult = regexp(YourCell, '^[a-zA-Z]{3},\s[a-zA-Z]{3}-\d{2}-\d{2}$');
nomatch = cellfun(@isempty, matchresult);
dateless = YourCell(nomatch);
datelike = YourCell{~nomatch};
Caution: this will not accept single digit day of the month as being a date. But it will accept any three letters as potential weekday name or month name. It will also not accept spaces before or after the date. (Some of these are easy to change but I am sticking with the format that you presented.)
  댓글 수: 2
AA
AA 2015년 10월 10일
thanks but it didnt work. When I click on datelike I only get one result which is 'Thu, Oct-08-15'. The rest is being ignored. Why is that?
'Thu, Oct-08-15'
'Thu, Oct-01-15'
'Thu, Sep-24-15'
'Thu, Sep-17-15'
'Thu, Sep-10-15'
'Thu, Sep-03-15'
'Thu, Aug-27-15'
'Thu, Aug-20-15'
'Thu, Aug-13-15'
'Thu, Aug-06-15'
'Thu, Jul-30-15'
'Thu, Jul-23-15'
'Thu, Jul-16-15'
'Thu, Jul-09-15'
'Thu, Jul-02-15'
'Thu, Jun-25-15'
'Thu, Jun-18-15'
AA
AA 2015년 10월 10일
brackets were wrong. now it worked. thanks
matchresult = regexp(YourCell, '^[a-zA-Z]{3},\s[a-zA-Z]{3}-\d{2}-\d{2}$');
nomatch = cellfun(@isempty, matchresult);
dateless = YourCell(nomatch);
datelike = YourCell(~nomatch);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by