From: Bayo on
Hi,

Is it possible to multithread in matlab? I mean running two programs (or m-file) approximately in parallel. I want read in some data via the serial port continuously (ideally in a forever while loop) in to a matrix. Then I wish to do further processing on the data matrix every time the matrix is updated.

At the moment I created a class for the data matrix and whenever it is updated it generates an event. I included the required code for further processing in the callback routine. Hence, it is more or less two threads (m-files) running in parallel. One reads data from the serial port continuously while the other process the data whenever new data is available.

Does anyone know if there is a better way of implementing this?

Please help!
Bayo
From: Steven Lord on

"Bayo " <ayb503(a)bham.ac.uk> wrote in message
news:hlb5e6$m21$1(a)fred.mathworks.com...
> Hi,
>
> Is it possible to multithread in matlab? I mean running two programs (or
> m-file) approximately in parallel. I want read in some data via the serial
> port continuously (ideally in a forever while loop) in to a matrix. Then I
> wish to do further processing on the data matrix every time the matrix is
> updated.
> At the moment I created a class for the data matrix and whenever it is
> updated it generates an event. I included the required code for further
> processing in the callback routine. Hence, it is more or less two threads
> (m-files) running in parallel. One reads data from the serial port
> continuously while the other process the data whenever new data is
> available.
>
> Does anyone know if there is a better way of implementing this?

You could try using a TIMER object.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ