Giter VIP home page Giter VIP logo

matlab-connector's Introduction

The matlab-connector library enables function execution on a remote MATLAB instance.

JSON is used as a platform and language independent.

Server setup

java -jar matlab-connector-1.1-SNAPSHOT-with-dependencies.jar <port> <threads> <path>

Using the Java client

Getting started

The connector is available on the UncertWeb Maven repository, hosted at the University of Münster. Adding the following snippet to your pom.xml file will include the repository in your project.

<repositories>
  <!-- Other repositories may be here too -->
  <repository>
    <id>UncertWebMavenRepository</id>
    <name>UncertWeb Maven Repository</name>
    <url>http://giv-uw.uni-muenster.de/m2/repo</url>
  </repository>
</repositories>

The dependency for the connector can then be added.

<dependencies>
  <!-- Other dependencies may be here too -->
  <dependency>
    <groupId>org.uncertweb</groupId>
    <artifactId>matlab-connector</artifactId>
    <version>1.1-SNAPSHOT</version>
  </dependency>
</dependencies>

Evaluating a MATLAB function

To execute a function in Java. Host can be localhost, or remote.

// Create handler instance
MLHandler handler = new MLHandler();

// Build request
MLRequest request = new MLRequest("do_a_sum");
request.addParameter(new MLScalar(2));
request.addParameter(new MLScalar(2));

// Send request
MLResult result = handler.sendRequest("localhost", 44444, request)

// Print result
System.out.println(result.toString());

Build

If you wish to build the project from source, the matlabcontrol 4.1.0 library is required. As this is currently unavailable on most Maven repositories, you can instead manually download the JAR file and install locally:

$ mvn install:install-file -Dfile=matlabcontrol-4.1.0.jar -DgroupId=matlabcontrol -DartifactId=matlabcontrol -Dversion=4.1.0 -Dpackaging=jar

Then build:

$ mvn clean package

Tests will fail unless a local MATLAB installation can be found.

Limitations

Security has also been overlooked in the current version, I'd recommended restricting access to the port the server runs on until access control is implemented.

matlab-connector's People

Contributors

itszootime avatar lushc avatar

Watchers

 avatar  avatar

matlab-connector's Issues

Can't pass NaN

Due to JSON not allowing NaN, we can't pass this as a value.

Switch to HTTP?

Might give some more flexibility - ability to add authentication, different data types for request (JSON and MessagePack). Jetty might be a good choice.

Reset working directory

At the moment, the connector relies on well-behaved functions which have not modified the current working directory after execution. It would be possible to add safety for functions which aren't so well-behaved, so they current working directory is reset after every request.

Potentially not that useful - functions are loaded upon server start, and any function which is interested in a specific directory should know the exact path to change to?

MATLAB starting mechanism

It may be possible to run the remote server all from a JAR, which is easier than having to maintain a MATLAB script + Java code. The matlabcontrol library can run a local MATLAB instance which could be kept in memory for the time the server is running.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.