Import Hours from .csv without colon

조회 수: 2 (최근 30일)
Grant Lockridge
Grant Lockridge 2018년 6월 20일
편집: Pieter Hamming 2018년 6월 20일
I have a time series data set that I need to import into Matlab. The hour time data are in the following format: 30 100 130 200 ...
I cannot get Matlab to recognize all of the hour values because there is no delimiting colon and the variation in the number of characters (two characters for 30, and up to 4 characters for 1000 for example).
Any suggestions?
  댓글 수: 2
Stephen23
Stephen23 2018년 6월 20일
What does 30 represent? What does 1000 represent?
Grant Lockridge
Grant Lockridge 2018년 6월 20일
time of day. 30 would be the equivalent of 00:30, 1000 would be 10:00. Additionally, 1300 would be 13:00 and 2100 would be 21:00

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

답변 (1개)

Pieter Hamming
Pieter Hamming 2018년 6월 20일
편집: Pieter Hamming 2018년 6월 20일
Lets say D is a column-array of your data:
D=[30;100;1200;330];
All digits before the last 2 are hours, so lets extract them:
hours=floor(D./100); %for our example data: hours=[0;1;12;3];
Substract the hours from the original data to have only the minutes left:
minutes=D-hours.*100; %for our example data: minutes=[30;0;0;30];
Either you're done now, or you can make a duration array out of it: dur=duration(hours,minutes,0);

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by