22

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.

3

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

3 Comments

kellogs, I need to do this in C (not Java or COM), can you point me in the right direction? Thanks.
just got here, if you still need pointers - search your documentation for stuff like mexFunction - the entry point in the C module, mxGetPr, mxCreateDoubleMatrix - functions for working the data out of/ into Matlab.. sorry, but I have uninstalled Matlab from my computer. Oh, and be careful about matrices as Matlab works with m[j][i] where you would normally work with m[i][j] (columns come first in Matlab)
kellogs, I think I'm well acquainted with MEX function. I'm actually using the loadlibrary/libpointer/libstruct approach to interface to a DLL that communicates with another server. That DLL can have asynchronous events, I'd like to be able to propagate those events back to Matlab. I've seen (and actually use) some approaches in Java that do this. I'd like to find a pure C/C++ way to do the same event propagation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.