필터 지우기
필터 지우기

Converting a Column to Numeric for Date/Time Format

조회 수: 4 (최근 30일)
Sarah Nolt-Caraway
Sarah Nolt-Caraway 2021년 3월 23일
댓글: Adam Danz 2021년 3월 23일
I am trying to convert the first column to a character string, so I can split the character string values to create a Date/Time format to sort data later on. When I try to isolate the column in Matlab, it skips the first column and uses only the second column. Can anyone help me isloate the first column?
This is what I have tried so far
T = xlsread('Vibes.xlsx');
C = str2double(T(:,1));
T = xlsread('Vibes.xlsx');
C = T(:,1);

채택된 답변

Steven Lord
Steven Lord 2021년 3월 23일
If you use the Import Data tool (in the Variable section on the Home tab of the toolstrip) you can import the data directly as a datetime array. Just specify the format. If you have multiple of these files in the same format to import, you could even create a script or function to automate the import process for the second and later files (and to see the code MATLAB used to import the data so you can learn from it.)
  댓글 수: 3
Sarah Nolt-Caraway
Sarah Nolt-Caraway 2021년 3월 23일
The underscore between the Date and Time in the first column is what is causing this error, hence why I need to separate them
Adam Danz
Adam Danz 2021년 3월 23일
They underscore can be included in the input format.
date = '2020-09-11_04:11:50.648000';
datetime(date,"InputFormat",'yyyy-MM-dd_hh:mm:ss.SSSS')
ans = datetime
11-Sep-2020 04:11:50

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

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