kmccoy
kmccoy

Reputation: 2861

How do I notify a MATLAB object of an event in a Java object?

For simplicity, say I have a Java object which generates a random number at randomly spaced time intervals. I wish to have a MATLAB object notified every time one of these random numbers is generated (so that the MATLAB object can then perform some task on the data).

How can I implement something like this? How can I have the Java object notify a MATLAB object that something has happened?

P.S. I am a strong programmer in MATLAB but fairly new to Java.

Upvotes: 22

Views: 1103

Answers (2)

A.DREY
A.DREY

Reputation: 38

I don't know, with java how to communicate with Matlab. But you should use Observable objects. And implements yours. Observer will send "notifications" that something has changed when observable object notify it to the EDT.

That's called Observable pattern.

Maybe take a look : https://docs.oracle.com/javase/7/docs/api/java/util/Observer.html

Best regards.

Upvotes: 1

kellogs
kellogs

Reputation: 2857

I have only done this from C, and it seems to be the better option. Anyhow, following

http://undocumentedmatlab.com/blog/jmi-wrapper-remote-matlabcontrol/

it looks like the best way would be to make use of the documented support for a COM interface (Windows) and process pipes (Unix/Mac).

Hope it helps

Upvotes: 0

Related Questions