Calling the callback handler / matlab function from Java

How to pass the handle of the matlab function to a Java object and call it from within Java (that is, I want Java to tell Matlab when it was ready to be evaluated). I am trying to use the com.mathworks.jmi.Matlab class to evaluate Matlab expressions in a Java object, but I don’t see how 1) pass the funcktion callback handle to Java and 2) call it from Java, possibly using the com.mathworks.jmi class. Matlab

Thanks Jakob

+6
java callback matlab function-handle
source share
5 answers

Hm. It seems that JMI is one of those internal tasks that may be changed in future versions. I found these online articles, not sure if they will help in your case.

+2
source share

I'm afraid I don’t know how to do exactly what you requested, but there are two ways to do something like this:

1) If you set up a Java callback from Matlab, you can send it a handle to the Matlab function. When the Java callback event is raised, the Matlab function will be activated. An example of this can be found here: http://UndocumentedMatlab.com/blog/uicontrol-callbacks/ . Please note that JMI is not required to run.

2) JMI needs a string (function name or command line) to evaluate Matlab. If you know the name of the function in advance, you can use it. Otherwise, you can prepare the Switch-yard Matlab function (whose name is known in advance) to dynamically direct your callback to the corresponding Matlab action.

I plan to launch an article on JMI at http://UndocumentedMatlab.com in mid-April, so stay tuned ...

Yair Altman

+1
source share

matlabcontrol is a Java API that allows you to do this. It can call the MATLAB function using feval. It cannot work directly with the function descriptor, but as mentioned in KitsuneYMG, you can use func2str to convert the function descriptor to a string. To get started, you can take a look at walkthrough .

+1
source share

To pass the callback to matlab, you pass the matlab function name and arguments to com.mathworks.jmi.Matlab.feval ("matlabControlcb", ..., 0); ... is Object [], where [0] = command and [1..end] = arguments.

See also FEVAL FUNC2STR

0
source share

try this tool: http://jamal.sourceforge.net/

It does exactly what you need and is well documented.

The basic principle on which it is based is to invoke RMI on the server side, which runs inside Matlab. The result is returned to the java program. Again, it depends on jmi ...

0
source share

All Articles