How to integrate Matlab code library with Android?

If you have an additional product, MATLAB Builder JA for Java, you can produce a .jar file from your MATLAB code.

However, the .jar file requires the MATLAB Compiler Runtime (a freely redistributable component that you get with MATLAB Compiler and MATLAB Builder products) to be present. The MCR has a much larger footprint than is suitable for the typical Android device (it’s like a copy of MATLAB itself, without the user interface).

You could think about either

  1. Running your MATLAB .jar file remotely on a server, and having your Android application connect to it, or
  2. Instead of using MATLAB Compiler and Builder products, use MATLAB Coder, which will convert a subset of the MATLAB language directly into C code. This C code doesn’t require the MCR, and could be compiled to run directly on Android. Make sure your MATLAB algorithm falls within, or can be expressed in, the appropriate subset of the MATLAB language.

Edit: As of R2015a, functionality from MATLAB Builder JA for Java has been replaced by a new product, MATLAB Compiler SDK.

Leave a Comment