extract date from cell of mixed types

5 次查看(过去 30 天)
Utsav
Utsav 2016-3-23
回答: BhaTTa 2024-11-21,4:22
[dom,txt11,raw11]=xlsread('datasheet.xls',9,'A:A'); yields [] for dom, cell for txt11 and for raw 11 the following is output 'Date' '01/06/2014' '02/06/2014' '05/06/2014' 'NaN' 'NaN' I wish to get the day information from the raw11 data. day(),month(), etc in excel are throwing garbage and I cant use their output to MATLAB.

回答(1 个)

BhaTTa
BhaTTa 2024-11-21,4:22
Hey @Utsav, When you import data from Excel using xlsread in MATLAB, and the date information is stored as text, you need to convert these text representations into MATLAB's datetime format to extract the day, month, or other components. Here’s how you can do it:Steps to Extract Day Information
  1. Read the Data: Use xlsread to import the data.
  2. Convert Text to Datetime: Use datetime to convert the text data into datetime objects.
  3. Extract Day Information: Use the day function to extract the day from the datetime objects.
Please refer to below documentation on datetime and day.

类别

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