Post by Yair AltmanPost by Marco I'd like to use a Java Timer (util.java.Timer) instead of matlab timer object. My only problem is that Java Timer Class need to define a TimerTask derived class with the proper run() method. How can i invoke Matlab code in the run method?
Thanks in advice for any useful information
You'll need to use JMI to call Matlab from Java. Note however, that JMI needs to wait for the main Matlab computational thread, so the benefits of using a Java thread may be diminished.
Yair Altman
http://UndocumentedMatlab.com
I just though of a neat hack that would bypass the need for JMI: in your Java run() code, simply raise an event (see http://www.mathworks.com/matlabcentral/newsreader/view_thread/272321 for sample code) on a Java object that is loaded in Matlab. In Matlab, listen on this event using a simple callback or a handle.listener. Then the corresponding Matlab callback code would be invoked when the Java run() is encountered.
Yair Altman
http://UndocumentedMatlab.com