f



Get a result from Matlab to Java (Call Matlab from JAVA

Hi all,

I am having trouble getting the return value from matlab to JAVA. 

I have tried Kamin Whitehouse 's code(matlabcontrol.java) and get working for eval and feval, but having trouble using blockingFeval function which returnts the value of matlab.

The problem I am having is it returns some value valid only in matlab workspace and when I play around with the return value in matlab, it works fine but in Java program it is just junk data. 

I corresponded with Kamin and he thinks that jmi.jar has been changed since he developed the class. The matlab library now returns the handle of the data, and not the data itself. Anybody has a clue of handling this problem? 
Thanks

-----------------------------------------------

I attached some results regarding this problem

> In blockingFeval function in matlab control
>
> public Object blockingFeval(String command, Object[] args) throws
> InterruptedException {
>     returnVal=new String("noReturnValYet");
>    Matlab.whenMatlabReady(new MatlabBlockingFevalCommand(Command, args,
> useCb, this);
>    if(returnVal.equals(new String("noReturnValYet"))) {
>        synchronized9returnVal) {
>           returnVal.wait();
>       }
>    }
>    //**********no change above this point **********
>    System.out.println("returnvalue in matlabcontrol : " +
> returnVal.toString());
>   Object rets[]=new Object[1];
>   rets[0]=returnVal;
>    try {
>         feval(new String("disp"), rets);
>    }
>    catch(Exception e) { System.out.println("error"); }
>    return returnVal;
> }
>
> In Matlab,
>
> I ran "mc.testBlockingFeval('sqrt', 5);
> and the result is
>
>  >>mc.testBlockingFeval('sqrt',5);
> returnvalue in matlabcontrol : [D@186b11c
>        2.2361
>  >>

> So the first line only shows some junk data.. and it succesfully display
> the right value using "disp" function as on the second line of the result.
>

I am not an expert of matlab-java problem. If you got any solution, please enlighten me !

Thanks
0
zamzame (1)
2/2/2007 2:30:50 AM
comp.soft-sys.matlab 211266 articles. 23 followers. lunamoonmoon (257) is leader. Post Follow

0 Replies
1189 Views

Similar Articles

[PageSpeed] 33

Reply:

Similar Artilces:

Calling matlab from java (windows), and running the java code not using the matlab JVM
Hello, I want to know if there is a way to call matlab from java (in windows), but not by calling the java code from matlab. I want to use a different JVM than the one matlab uses. In linux it is simple since I can use input/output redirection, is there a way to do this in windows (I have matlab 5.3, pretty old version). Thanks a lot, Nili. ...

Call a Matlab function from Java running in matlab.
Hi guys. I really apologize for asking this question, since I'm sure it is either basic or not possible, but I have been reading through the documentation and can't seem to figure this out, since the examples look like they just send and receive variables from the Java methods. Could anyone give me a short example of how to call a method from a Java object that causes some sort of action to be performed in MATLAB? For example, I would like to: 1) make a new object of MyClass from MATLAB called MyObject. 2) run MyObject.DoSomethingInMatlab() 3) have a statement in DoSomethingInMatlab...

How to notify Matlab about Java object change in Matlab Java Interface?
Hello, Does anybody has any idea how to update Matlab function about Java object change ? It could be done by polling: while JavaObj.getValue()=='not done yet' pause(1); end But polling is evil. There should be more elegant way to do this job ... I've checked 'Matlab Java Interface' docs : http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f6671.html , but found nothing on the subject :( Thanks in advance for your help, Could you use javacomponent to set up the object, and set a callback to repond to the changed value? On Apr 21, 5:44=A0pm, &...

Calling matlab from java
Hello All I am trying to call Matlab from java. I am using Brad Phelan's matlab snippet http://xtargets.com/snippets/user/bradphelan/tag/feval to investigate how to do this but all I get is matlab showing "Busy" and basically hanging. I have tried commenting out the semaphore control which "helps" but I then get a null exception because the return value is null. I call my test routine from matlab as follows: TestMat.main({}) My test routine looks like Brad's example: public class TestMat { public static void main(String[] args) { MatlabFunction<Double> f = new MatlabFunction<Double>("times"); double x = f.execute(10,20); //System.out.println("x is " + x); } } My environment is: matlab 7.1.0.246 (R14) Service Pack 3 Windows XP Can anybody help? Regards John Seers John Seers wrote: > Hello All > > > I am trying to call Matlab from java. I am using Brad Phelan's matlab snippet > > http://xtargets.com/snippets/user/bradphelan/tag/feval > > to investigate how to do this but all I get is matlab showing "Busy" and basically hanging. I have tried commenting out the semaphore control which "helps" but I then get a null exception because the return value is null. > > I call my test routine from matlab as follows: > > TestMat.main({}) > > > My test routine looks like Brad's example: > > public class ...

trying to get matlab java builder to return a java object
hi all, I'm trying out matlab java builder, one of the things I'm trying is to compile a matlab function that returns a java object, and call that function from a java app. So Matlab function -> calls java function -> returns java object another java function -> calls matlab function -> gets back ? i.e. is this possible and if so, how do i extract the object from the returned MWArray object. Thanks! Nick Nick, This is possible in R2007a. Your code would look as follows: <m-code> function x = foo x = java.lang.String('hello'); <java code> Foo f = new Foo(); Object[] r = f.foo(1); MWJavaObjectRef j = (MWJavaObjectRef)r[0]; String x = (String)j.get(); - Rachel Schiff <nicholas.choo@gmail.com> wrote in message news:1174055452.976379.171620@e1g2000hsg.googlegroups.com... > hi all, > I'm trying out matlab java builder, one of the things I'm trying is to > compile a matlab function that returns a java object, and call that > function from a java app. So > > Matlab function -> calls java function -> returns java object > another java function -> calls matlab function -> gets back ? i.e. is > this possible and if so, how do i extract the object from the returned > MWArray object. Thanks! > Nick > ...

Calling Compiled MATLAB from MATLAB
Hello everyone, How do I compile MATLAB M files into a form that can then be called from within the MATLAB interpreter? A roundabout way would seem to be to (somehow) Turn the matlab code into C (I think mcc does this), then compile this C code into MEX format and call that. Is there an easier way? I have the MATLAB compiler, so I just need to know what to do with it to get this to work. Thanks in advance, Sina sina.tootoonian wrote: > > > Hello everyone, > > How do I compile MATLAB M files into a form that can then be called > from within the MATLAB interpreter? A roundabout way would seem to > be > to (somehow) Turn the matlab code into C (I think mcc does this), > then > compile this C code into MEX format and call that. Is there an > easier > way? I have the MATLAB compiler, so I just need to know what to do > with > it to get this to work. > > Thanks in advance, > > Sina > > HELP MEX > HELP MEX Or, better, HELP MCC help pcode pseudo code is useful to obfuscate code - protect algorithms, yet still run at full speed and be distributable to other matlab users sina.tootoonian wrote: > > > Hello everyone, > > How do I compile MATLAB M files into a form that can then be called > from within the MATLAB interpreter? A roundabout way would seem to > be > to (somehow) Turn the matlab code into C (I think mcc does this), > then > compile this C code into MEX format and call that...

Calling of Matlab from java
Can Anyone tell me in detail how to call Matlab functions from a java program?? There may be one option called JMatLink?? Is it suitable to call all the possible functions of Matlab?? Waiting for an early response from somebody Thanking You Regards -Amit Anand ...

Calling Java from Matlab
I am unable to load user defined java classes into Matlab. java... classes load fine. I have updated classpath.txt in the starting directory to include the package parent directory. IMPORT wrt single class responds with: Arguments to IMPORT must either end with '.*' or else specify a fully qualified class name. Have tried compiling java with version 1.3 compatible which I believe may be required by Matlab. Software in use: Matlab 6 R12 Sun JDK 1.4.1_02 Community Any Ideas? experience? "John Edwards" <Hippies8MyStash@aol.com> wrote in message news:eedcad6.-1@webx.r...

Matlab builder JA: parse java string to matlab cell
Hi all, I'm building a java swing based GUI for my Matlab application. As such, user input is available as text strings, for example "{[0; 0], [3.5 0; 0 2]}" (mean vector and covariance matrix of a 2D Gaussian). The user input will be passed to the compiled matlab method as a MWCellArray. Problem is how do a convert (parse) the above string into a MWCellArray? From its javadoc http://www.mathworks.com/access/helpdesk/help/toolbox/javabuilder/MWArrayAPI/index.html the following method is available: java.lang.String toString() Returns a string representation of this array, but the reverse method is not. Evidently, parsing a string like the one above is a non trivial task and I'm loath to attempt writing one by myself. I would be very thankful if someone can point me to the required parser implementation. Matlab itself is carrying out this task all the time, perhaps it is possible to access Matlab's own parser. Help much appreciated, Ritesh ...

Java program using Matlab JA Builder can not find matlab libraries
Hi all: We are trying to run a java program calling Matlab. When we run our program, we get the following error: Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to find the library libmwmclmcrrt.7.10.dylib, required by MATLAB Builder JA, on java.library.path Therefore we proceed and add the following VM argument: -Djava.library.path=/Applications/MATLAB_R2009a.app/bin/maci/ Now we get a different error: Exception in thread "main" java.lang.LinkageError: dlopen (/Applications/MATLAB_R2009a.app/bin/maci/libnativemcl.jnilib, 9): Library not loaded: libt...

Attaching Java debugger to Matlab? How to debug Java?
Hi everyone, is there any way to debug a Java application that uses Matlab? I remember a while ago I was able to attach VisualCafe 3.1 (or something like that) to Matlab's VM and debug my Java code. I have not been successful in doing something similar with any other Java IDE or debugger recently, or figuring out the alternative. Does anybody know a way to debug Java code that runs within Matlab using a decent IDE? I am using Sun ONE Studio 4 at the moment. Thanks in advance. Nik -- ======================================= Nikita A. Visnevski Adaptive Systems Laboratory CRL,...

Calling Matlab From Java #10
Hi , My name's Christopher. Helping execute programs from java in matlab ? See yuo later "Christopher Zapata Reto" <c.zapata.reto@mathworks.com> wrote in message <f9aof0$egv$1@fred.mathworks.com>... > Hi , > My name's Christopher. > > Helping execute programs from java in matlab ? > > > See yuo later already answered today here ...

calling Matlab from Java #7
Hi, I am trying to acces Matlab functions from Java code. I tried to use Brad Phelan's code from http://xtargets.com/snippets/user/bradphelan/tag/feval and test class with main: public static void main() { class CallMatlab extends Thread { public void run() { MatlabFunction<double[]> f = new MatlabFunction<double[]>("times"); double[] x = f.execute(10,20); System.out.println(x[0]); } ...

JAVA in MATLAB
Hi! This might not be a MATLAB problem, but anyway, I dont know a better forum to post my question... It's a simple problem: I would like to print my table (class javax.awt.swing.JTable) I created by calling JAVA in MATLAB. (Preferably to a *.ps format so I can print it from unix.) I'm a beginner in JAVA, so I am really lost in the reference guide. There seem to be many ways to print something in JAVA but I cant put my finger on any certain way. What I would like to know is what direction I should look. Anything would be helpful, just to get me started... regards /Per later that ...

Calling java from matlab #7
Hi, I'm trying to build a database in Java (using MySQL), and the aim is to be able to call the connection from Matlab. I've built a .jar project with netbeans, and apparently it works when running in netbeans, but when I try to call from Matlab I've found some problems. I've updated my jvm in matlab, and be sure I add the project to the javaclasspath. More or less my code is as follows: javaaddpath('/home/ojki/Documentos/Oscar/Investigacion/DataBase/ cardiacDataModel/dist/cardiacDataModel.jar'); %Carga de las librerias que se utilizan, dispuestas en lib cd /home/ojk...

calling matlab commands from java
what is wrong with this code that i get the error below: package cmds; import com.mathworks.jmi.*; public class RunCommand { public static void main(String[] args){ Matlab myMatlab = new Matlab(); try{ myMatlab.eval("pwd"); } catch(Exception e){ System.out.println("failure!"); } } } Exception in thread "main" java.lang.NoClassDefFoundError: com/mathworks/services/message/MWHandler at cmds.RunCommand.main(RunCommand.java:7) ...

Calling Matlab from Java #8
I am trying to call Matlab functions from a Java program (Matlab 7, Java 1.5). I would like to use the code from http://xtargets.com/snippets/posts/show/32 as an interface such that I can call Matlab functions by sending strings. The problem is that I get no results when calling this program. The test class I am using is: public class Test { public static void main(String[] args) { MatlabFunction<double []> f = new MatlabFunction<double []>("times"); double x[] = f.execute(10,20); System.out.println(x[0]); } } and my project has references to ...

calling java from matlab #6
hi everyone, Does anyone know how to reference a user-defined Java class from Matlab? If so should the file be precompiled outside of Matlab first? I have the Java class file folder added to the class path, and used "import MyClass", but this doesn't work. The error message says Arguments to IMPORT must either end with ".*" or else specify a fully qualified class name: "MyClass" fails this test. Lynn The class must be precompiled into a valid .class file. This file must be on the java path (can use javaaddpath(pwd) and include the file in the current work...

Calling java class from matlab
Hello everybody I have a java class, and I need to call it from matlab to implement a document. is that you have an idea? "najmaf najma" <fola_hm@hotmail.com> wrote in message news:iq1tp8$la9$1@newscl01ah.mathworks.com... > Hello everybody > I have a java class, and I need to call it from matlab to implement a > document. is that you have an idea? http://www.mathworks.com/help/techdoc/matlab_external/f44062.html -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com this is my problem: this is the...

Matlab
Hi ! Small entering guide: I need a JAVA GUI for already existing MATLAB programs. Mathworks Link: <http://www.mathworks.com/company/newsletters/news_notes/win02/patterns.html> ode example [JAVA]: // -> IMPORT MATLAB ENVIRONMENT import com.mathworks.*; import com.mathworks.jmi.Matlab; import com.mathworks.jmi.MatlabException; public class matlab extends JFrame { // MATLAB INSTANCE private Matlab matlab; public matlab() { .... .... .... // CREATE MATLAB INSTANCE try { matlab = ne...

Call Java from Matlab #2
I'm working with Matlab R2006b on Windows. I 'm intesresting by the NetCDF Java package to access to data files for read and write. I've found some examples, I try on Matlab, in the document : NetCDF Java Users' Manuel (page 33-34). I need some help to call some classes of the librairy nc2.2.jar, particulary for writing files : all the classes type ArrayInt (Double, ...) for dimensions D1, D2, D3 .... I success to manage dimension, attribut, but I don't manage to create a array of data for any dimension I know. In Matlab, the instruction : ucar.ma2.ArrayInt.D3(2, latDim.g...

Calling Matlab Within Java
Greetings; How do I call (.m) scripts from within my Java code? I've googled around for answsers, but have not yet found an example that works. I'm on a linux box using javac, and have the latest version of matlab. I would like to call matlab functions from within my Java program and get the results. Cheers, Derek ...

Calling Java classes from Matlab
When I tried to call Java classes in matlab. I am getting following error ??? Error using ==> javaObject No constructor with appropriate signature exists in Java class sraghu. But I wrote the constructor everything is fine Is there any format for writting construtor. Please help me regarding this. Your constructors must be public. "Doppalapudi " <doppalapudiraghu@yahoo.com> ???????:f8qp8v$t7s$1@fred.mathworks.com... > When I tried to call Java classes in matlab. > I am getting following error > > ??? Error using ==> javaObject > No constructor with ap...

Calling Matlab from Java #12
Hi people, I am using the famous MatlabControl class to access Matlab from Java. It works fine. I wish to call a Matlab function that returns more than one variable? Any idea of how you do that?? Do you know how mtGet() and mtSet() work? Thanks a lot George ...

Web resources about - Get a result from Matlab to Java (Call Matlab from JAVA - comp.soft-sys.matlab

Result - Wikipedia, the free encyclopedia
A result (also called upshot ) is the final consequence of a sequence of actions or events expressed qualitatively or quantitatively. Possible ...

Facebook To Announce 1Q 2013 Financial Results May 1
Facebook has been a busy company in the past fiscal quarter, launching a redesigned News Feed and Timeline . Facebook will share how it did financially ...

Jared Tallent wins gold after drug cheat's results stripped
Australia has a new Olympic gold medalist. Three-and-a-half years after being beaten over the line by a Russian drug cheat walker, Jared Tallent ...

Jared Tallent wins gold after drug cheat's results stripped
Australia has a new Olympic gold medalist. Three-and-a-half years after being beaten over the line by a Russian drug cheat walker, Jared Talent ...

Australian race walker Jared Tallent to be awarded gold medal from London Olympics after Russian’s results ...
... medal for the 50km race at the 2012 London Olympics after the Russian winner was disqualified for doping. The CAS ruled all competitive results ...

Hair testing positive results: AFL pleads for patience, won't release more information
The AFL has rejected Jeff Kennett's call for all illicit drugs results from the summer hair testing of players to be released, declaring the ...

Video: Man lights 6,000 matches and the result is mesmerizing
... good idea to line up 6,000 matches in close proximity, light a lone match, and then record what happens next. Suffice it to say, the end result ...

NCAA Tournament 2016: B/R Expert Predictions, Updated Results for Elite 8 - Bleacher Report
After Saturday's action, we now have the first two tickets punched to the Final Four. Oklahoma used POY favorite Buddy Hield's 37-point explosion ...

Angry Ram Takes on the Easter Bunny With Squeaky Results
Submitted by: (via Angry Ram ) Tagged: ram , Easter Bunny , sheep , Video Share on Facebook

MGM Ends A Financially Strong 2015 With Mixed Q4 Results
MGM roared today about its strong financial performance for all of 2015, although its results in the last three months of the year appear mixed. ...

Resources last updated: 3/27/2016 10:13:45 PM