Import Hours from .csv without colon
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!