Results 1 to 7 of 7
  1. #1
    Niroshan is offline Member
    Join Date
    Oct 2009
    Posts
    1
    Rep Power
    0

    Question How to apply a patch (Call Matlab from Java)

    I want to call matlab functions from java. I found an interresting article which says how to do it.

    My problem is, I think I need to apply a patch to get it working and I hava the code, but i have no idea how to apply it.
    Any help is hightly appreciated. Thank You.

    here is the patch code

    Index: MatlabControl.java
    ================================================== =================
    RCS file: /cvsroot/tinyos/tinyos-1.x/tools/java/net/tinyos/matlab/MatlabControl.java,v
    retrieving revision 1.3
    diff -u -r1.3 MatlabControl.java
    --- MatlabControl.java 31 Mar 2004 18:43:50 -0000 1.3
    +++ MatlabControl.java 16 Aug 2004 20:36:51 -0000
    @@ -214,7 +214,8 @@
    matlab.evalConsoleOutput(command);
    }
    else{
    - matlab.fevalConsoleOutput(command, args, 0, null);
    + // matlab.fevalConsoleOutput(command, args, 0, null);
    + matlab.fevalConsoleOutput(command, args);
    }
    } catch (Exception e) {
    System.out.println(e.toString());

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,530
    Blog Entries
    7
    Rep Power
    20

    Default

    If you're running a un*x box you can run 'patch' to do the job (also see "man patch"). The patch program takes a diff file (the thing you dispayed) and a source file and applies the patches listed in the diff file to the source file; if you don't have patch available you can always apply the patches manually (just edit the source file). - means delete the line, + means add the line. Also google for "unix apply patch" for the exact syntax of diff files.

    kind regards,

    Jos

  3. #3
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    in unix there is a patch command, likely if you are in the top level folder
    Java Code:
    patch -i the_patch_file.patch
    Eclipse IDE supports applying a .patch file to a project, but this requires you to have the sources set up in a workspace, which can be a pain if you don't already use eclipse.

    in this case, you could just open up this MatlabControl.java, go to line 214, and comment out

    matlab.fevalConsoleOutput(command, args, 0, null)

    and adding after it

    matlab.fevalConsoleOutput(command, args);


    You would then need to rebuild these java sources, such as using what ever instructions were given with this package. Most projects now use ant or maven tools for this. hopefully there is instructions for doing this.

  4. #4
    Klop is offline Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Default Calling Matlab from Java

    http://jamal.sourceforge.net/ It is decently documented, has some examples and does really good job if you need call Matlab from Java.

  5. #5
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    I've written applications that interact with matlab via Runtime.exec. Matlab has a terminal mode that facilitates piping information back and forth via stdin/stdout. This is handy if you need to run a filter design tool or something like that and want to interract with the results.

    Matlab also has direct Java support built-in, so you can instantiate a java object from Matlab and interract that way too.

  6. #6
    nonother is offline Member
    Join Date
    Jul 2011
    Posts
    1
    Rep Power
    0

    Default Java API to call MATLAB from Java

    matlabcontrol is a Java API which makes it very easy to call MATLAB from Java. It can do everything the MatlabControl class can and do more, including controlling MATLAB from a Java application running outside of MATLAB. Using the API is as if you were interacting with MATLAB's Command Window, and you can retrieve the results as Java objects. To get started, take a look at the walkthrough.

  7. #7
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    This thread is pretty old(1 year since last post, 2 years since original post), please don't resurrect old threads.

Similar Threads

  1. run a matlab script from java
    By npoorni in forum Advanced Java
    Replies: 5
    Last Post: 02-11-2010, 03:32 PM
  2. Help, Integrate a Java with Matlab
    By toby in forum Advanced Java
    Replies: 2
    Last Post: 08-07-2008, 07:08 AM
  3. Replies: 3
    Last Post: 04-10-2008, 09:01 AM
  4. Need help in releasing a patch to Java application
    By venusunil in forum Advanced Java
    Replies: 1
    Last Post: 10-31-2007, 09:35 PM
  5. Replies: 1
    Last Post: 08-07-2007, 07:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •