user1574598
user1574598

Reputation: 3881

MatLab - Modify Tic Toc Return Value

I am using the tic and toc within MatLab which is returning a double of hrs, mins, secs, etc. Is there a way to force the return value so it returns milliseconds in the form of an long unsigned integer?

One of my variables starts defined as an integer diff1 = int32(0), but when I do a calculation on two other variables that store the return value from tic and toc, diff1 gets converted back to a double.

Upvotes: 0

Views: 214

Answers (1)

Luis Mendo
Luis Mendo

Reputation: 112659

You can do the conversion manually:

uint32(floor(toc*1000)); %// or "round" instead of "floor"

Example

>> tic, randn(1000); t = uint32(floor(toc*1000))
t =
          49

>> whos t
  Name      Size            Bytes  Class     Attributes

  t         1x1                 4  uint32 

Upvotes: 1

Related Questions