No BSD License  

Highlights from
Convert 24/12 Hr. time string to a unique number

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 2.58 KB File ID: #22613

Convert 24/12 Hr. time string to a unique number

by Aniket

 

07 Jan 2009

Converts a string like '14:21:3:221" to a unique integer number.

| Watch this File

File Information
Description

The integers run from 0 to 86399999 corresponding to 00:00:00:000 to 23:59:59:999 respectively.
List of functions used:
isstrprop
strtok
str2num
strcmp

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
08 Jan 2009 Jos (10584)

First, what use does this submission offer, except as a simple programming example, since we are already equiped with DATENUM?
Second, what about actually using datenum to get these integer values; something like:
datenum(0,0,0,H,M,S) ./ datenum(0,0,0,0,0,0.001)

08 Jan 2009 Aniket

You are right Jos, that this is possible...
In my case, I was doing some additional time processing because of which I had to write that function...and thought it could be useful on the web...without thinking about datenum()...

08 Jan 2009 Aniket

Another comment I wanted to add:
the datenum() function [the way we use it here..] does exactly what my last line of code does. So to answer your question of what purpose this code serves, is it checks for string validity to conform to a time string..
So for people who do not want to write that from scratch, this code could be used off-the-shelf.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
convert time Aniket 07 Jan 2009 16:26:47
convert 2412 hrs time to integers Aniket 07 Jan 2009 16:26:47

Contact us at files@mathworks.com