Reading a text file containing colon mark
3 次查看(过去 30 天)
显示 更早的评论
I have a text file (a) contains words and numbers and colons. I would like to use the fscan and the fread function to get a time. However, the time is like this 2:30:20
I wonder, how can I do that such that there are cono(:) marks in between.
B=fread(a,time,'uint16');
I think the problem is in the uint16, but I don't know how to solve that.
Thanks in advance for your help
回答(1 个)
Krishna Anne
2019-5-30
Looks like you are getting the time as "Duration" class, Try one of these as required to fetch hours or seconds or minutes or milliseconds etc.
milliseconds(time) or
seconds(time) or
hours(time) or
minutes(time)
..........etc, provided time has class 'duration' you may check by typing class(time)
16 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!