Click here to Skip to main content
15,887,262 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm doing a project about the accuracy of the time until the micro-seconds in matlab, how to access the micro-seconds of time from the processor?
Posted
Comments
Manfred Rudolf Bihy 25-Apr-11 4:38am    
You sure do like to spread your question around do you: http://www.mathworks.com/matlabcentral/answers/6151-micro-second.
Why don't you have a picture in you CP profile like on the above site?
Richard MacCutchan 25-Apr-11 5:21am    
Try using the system time, lots of different ways to get it in C, C++, C# etc.
paskah 26-Apr-11 3:24am    
thanks for the answer, whether the code above can be imported into matlab, because the language that I use is matlab?and my interface to serial communication using matlab, can you help me, thanx
Richard MacCutchan 26-Apr-11 3:50am    
Sorry, I have no experience with matlab, but I know it has some interface that allows it to access C++ code (or vice versa). Your best resource would be the matlab website(s).
Albert Holguin 26-Apr-11 11:34am    
here's a tutorial for pulling C++ into matlab:
http://www.engineering.uiowa.edu/~dip/lecture/C++_with_Matlab.pdf

im realy nedd this code,please help me.
 
Share this answer
 
I agree with Richard, "Try using the sytem time,lots of different ways to get it in C, C++, C# etc."

Here is one example.

C#
using System;
using System.Threading;

namespace timeTOmicro
{
   class Program
   {
      static void Main( string[] args )
      {

         long systemClock1 = DateTime.Now.Ticks; Thread.Sleep( 2 );
         long systemClock2 = DateTime.Now.Ticks;



         long nanoSecondsBetweenTimes = systemClock2 - systemClock1;

         Console.WriteLine( nanoSecondsBetweenTimes + " nano seconds between clock samples " );

         Console.ReadLine();
      }
   }
}
 
Share this answer
 
Comments
Albert Holguin 25-Apr-11 20:24pm    
Do you even know what Sleep() does?
paskah 26-Apr-11 3:24am    
thanks for the answer, whether the code above can be imported into matlab, because the language that I use in my final project is matlab?
Albert Holguin 26-Apr-11 11:29am    
You don't want to use that code, it makes no sense and will not get you what you're looking for.
paskah 27-Apr-11 1:13am    
if you can tell me what the correct code, I really need it.thanx mr.albert holguin
Albert Holguin 27-Apr-11 10:54am    
the tricky part would be to get accurate resolution at that level, there's a ton of ways to do it in, google the topic... but this code above is wrong, Sleep() takes arguments in milliseconds, off the back, there's a 2 millisecond delay between his two calls

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900