views:

211

answers:

2

I'm trying to get data from a server. Right now, I am polling the server every couple of seconds for the current values. I am wondering if it is possible to have Matlab get the data in real-time or if I am stuck with my current implementation. Has anyone done anything like this? If so, maybe you can tell me how you got started with it.

Any help would be greatly appreciated. Thanks!

+2  A: 

If you're on Windows, you can listen to ActiveX (COM) events using REGISTEREVENT. You would need to provide an ActiveX control (servers might work too, I'm not sure) that triggers the event, which would invoke your MATLAB function.

mtrw
Thank you for the suggestion! I'm not very familiar with using ActiveX, but would this be able to interrupt a Matlab script that is already running?
Shaka
I doubt it. I think callbacks only run if nothing else is running at the time. Another approach might be to have the ActiveX object harvest the data in a thread, then make it available to MATLAB via a function. This would be sort of like your current polling solution, but the thread would be under your control so you ensure it's fast enough.
mtrw
A: 

Matlab timers work well for periodic events. You'll want to be careful about making sure your function executes in less time than the periodicity of the timer, though settings for the behavior when that doesn't hold do exist.

Mark E

related questions