File Exchange Pick of the Week

Our best user submissions

parseTime

Will‘s pick this week is parseTime by Robert.

Sometimes it’s something simple that ends up being the most handy. I can’t tell you how many times I’ve run a simulation whose base unit of time is seconds. For long simulations, you end up with some rather big numbers. At that point, it’s often more useful to think of the values in hours, days, and/or years. And so I end up at the MATLAB Command Window typing t/60/60/24…

MATLAB’s datetime data type has drastically simplified a lot of my time-related analysis tasks. However, I still find myself running my quick conversions on double-precision numbers. That’s where parseTime comes in. This no-frills function returns the equivalent years, weeks, days, hours, minutes, and seconds.

parseTime Output

I’ll be adding this function to my path and expect to be invoking it regularly. The one thing I’d like added is support for arrays. It’s a small modification that most MATLAB programmers should be able to achieve on their own.

Let us know what you think here or leave a comment for Robert.

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.