How to run matlab script from java (for android) using matlabcontol.jar
android, java, matlab
Solution
`matlabcontrol` just gives you a way to call a running copy of MATLAB from Java. If you have some MATLAB code that you want to run on an Android device, this is not going to work for you, as there is no version of MATLAB that will run on Android.
If you have MATLAB code that you'd like to run as part of an Android application, you have two real choices:
i) Use MATLAB Coder to convert the MATLAB algorithm to C code, that can be compiled, called from Java, and included in your app to run on the device. You'll need to ensure that your MATLAB algorithm falls within the subset of the MATLAB language that is supported by MATLAB Coder, but that usually isn't a big issue. MathWorks have a recorded webinar with a worked example of how to do this (it's Objective C on iPhone rather than Java on Android, but the principles are the same). It's called something like "MATLAB to iPhone made easy", if you want to look it up. Here's the link to it.
ii) Use either MATLAB Builder NE for .NET, or MATLAB Builder JA for Java to deploy your MATLAB algorithm as a web service, and have your Android application call that web service.
PS MATLAB Mobile is not a relevant option here - it is a tool for connecting to a MATLAB session on your machine or in the cloud, and interactively running MATLAB code. It does not give you a way of running MATLAB code on the device itself.
Problem
I am trying to call up a user defined `matlab` function(`.m` file) from java android application which is developed in Eclipse using `matlabcontrol.jar`. Actually, It works well when I use it in the java project. But I wonder is it possible to use it when I develop android application. The problem is When I use `matlabcontrol.jar` for java project, it pops up and runs `matlab` application(like `R2009b matlab`) automatically, even though I don't want to use it. then run and print result on the `matlab` console also. Then, I think, if someone who didn't install `matlab` application in their computer or smartphone can't use application which is included `matlab` code. So, I just want to run `matlab` code on java program(for android), not using `matlab` application. Give me option or alternative way to work out please? Please help. Thanks.