Hi,
I am transfering the data from ultrasonic sensor into the excel file attached and using the code below but I am keep getting error that my data not in right format, it ask me firstofall to read the data in matric rather then table I done both but still getting error. " i want to understand what am i doing wrong and how to correct it" please
Error while reading as table:
Error using datetime (line 597)
Numeric input data must be a matrix with three or six columns, or else three, six, or seven separate numeric arrays. You can also create datetimes from a
single numeric array using the 'ConvertFrom' parameter.
Error in dateformat (line 5)
th = datetime(Hdat.TimeStamp,'InputFormat','dd.MM.yyyy HH:mm:ss.SSS');
Error while reading as Matrix:
Dot indexing is not supported for variables of this type.
Error in dateformat (line 5)
th = datetime(Hdat.TimeStamp,'InputFormat','dd.MM.yyyy HH:mm:ss.SSS');
Code Used:
Hdat = readtable('F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_D\Data_Head\Data_Raw\Head_Timestamps.xlsx');
th = datetime(Hdat.TimeStamp,'InputFormat','dd.MM.yyyy HH:mm:ss.SSS');
h = Hdat.Head_mm_;

 채택된 답변

Arif Hoq
Arif Hoq 2022년 3월 13일
try this syntax:
th = datetime(A.TimeStamp,'InputFormat','dd.MM.yyyy HH:mm:ss.SSS','ConvertFrom','datenum');

댓글 수: 5

Hi this worked but answers coming in this form as shown below '31-Dec--0001 13:31:43' is there anyway it only show '13:31:43' timestamp
Stephen23
Stephen23 2022년 3월 13일
편집: Stephen23 2022년 3월 13일
  • 'InputFormat' is used to specify how to interpret text input data.
  • 'ConvertFrom' ise used to specify how to interpret numeric input data.
It does not make any sense to specify both of them. I am surprised it does not throw an error.
Thanks for the further clarification steven.
try this:
th = datetime(A.TimeStamp,'Format','HH:mm:ss','ConvertFrom','datenum');
These are almost certainly NOT datetimes, but rather durations. See my response to your other, nearly identical, post:

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 3월 13일
As discussed in your other Question, the field in the file stores fraction of days in numeric form, and has no date information.
th = days(A.TimeStamp);
th.Format = 'hh:mm:ss' ;

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2022년 3월 13일

댓글:

2022년 3월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by