필터 지우기
필터 지우기

How to remove letters from cell arrays

조회 수: 3 (최근 30일)
Matheus  Pacifici
Matheus Pacifici 2019년 8월 30일
댓글: Guillaume 2019년 8월 30일
When I import data from a speficic excel table, each row of one column comes as follows:
'2019-08-20T13:58:31Z'
In order to use 'datestr' or 'datevec', I need to delete the T and the Z on each row.
How can I delete these 2 letter for every row of the column?

채택된 답변

Stephen23
Stephen23 2019년 8월 30일
편집: Stephen23 2019년 8월 30일
Why do you need to delete them?
>> str = '2019-08-20T13:58:31Z';
>> datevec(str,'yyyy-mm-ddTHH:MM:SS')
ans =
2019 8 20 13 58 31
  댓글 수: 1
Guillaume
Guillaume 2019년 8월 30일
Note that by using datevec you've completed lost the fact that the original dates were in the UTC timezone.

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

추가 답변 (1개)

Guillaume
Guillaume 2019년 8월 30일
Don't use the ancient datestr or datevec particularly for dates as you have that are timezoned since these don't support time zones.
Instead use the modern datetime that fully understand time zones. To convert your dates to datetime:
d = datetime(yourcellvector, 'InputFormat', 'yyyy-MM-dd''T''HH:mm:ssZ', 'TimeZone', 'UTC'); %or use your own timezone instead of UTC. The time will automatically be adjusted to your timezone

카테고리

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