As this latent coupling will be a frustrating limitation. I would recommend not pursuing this solution of the MATLAB controlling the timing of Step Motors, remotely. You can always email me (altmany at gmail) for private consulting. So actual time between pulses using MATLAB's delay is 0.001 pause plus the time of baud rate times the packet size and decoding then execution. I reserve the right to edit/delete comments (read the site policies). Wrap code fragments inside tags, like this: The interesting thing is that for time duration in between >1ms and or are accepted. Sleep() over it…Īs you said, in the new MATLAB versions the pause performs the same or even better for some pause duration. So if you want accurate and leak-free pauses, and do not need the EDT side-effect, I really see no reason to use Matlab’s pause. However, as the above results clearly show, in practice the Java variant is much more accurate than Matlab’s. A few weeks ago I talked about the new pause button in Release 2016a on the editor tab of the desktop. Java’s Thread.sleep function, like Matlab’s pause(), is not guaranteed to pause for the exact duration specified. This side effect is actually quite important when integrating Java GUI components in Matlab figures. In my tests above I did not have any open figures, otherwise I suspect the discrepancy would only have been larger. Matlab’s pause function has an important side-effect, that may partly explain the discrepancy: Whenever pause is called, the graphics event queue ( EDT) is flushed, thereby updating all Matlab figure windows. On the other hand, Java’s inaccuracy remains stable at <1 mSec, making its relative inaccuracy degradation much more gradual and acceptable (8% at 0.01, 20% at 0.005). The effect of increasing absolute inaccuracy with decreasing total pause duration is catastrophic. Apparently, Matlab’s pause function has an inherent inaccuracy of several mSecs that increases as the pause duration decreases. When the pause duration is further reduced, Matlab’s inaccuracies increase (120% at 0.01, 370% at 0.005) to a point where we cannot in practice rely on them. When the pause duration is reduced to 50 mSecs (0.05 secs), the results are even more striking: Function But I only use pause if the animation requires little data, since pause () blocks processing for the ammount of time given. It is my preferred method since it is simple and straightforward. The results are consistent and conclusive: Function 1) pause (): pause () can be used for simple animations with little data. (duration*1000) % Note: sleep() accepts duration Pause(duration) % Note: pause() accepts duration sleep (duration* 1000 ) % Note: sleep() accepts duration TSleep (timesToRun ) = 0 % pre-allocate for idx= 1 : timesToRun Tic pause (duration ) % Note: pause() accepts duration tPause (idx ) = abs (toc-duration ) end % Measure Java's sleep() accuracy TPause (timesToRun ) = 0 % pre-allocate for idx = 1 : timesToRun Duration = 0.25 % % Measure Matlab's pause() accuracy
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |