0

I have a simulation in Java in which I need to call a MATLAB optimizer every 2 minutes (simulation time) and read the data back into the Java program.

I know there are answers for running MATLAB scripts, but is there any way to run a single MATLAB script from Java while keeping the connection between Java and MATLAB open for the entirety of the simulation?

In other words, I do not want to have the computer to have to start up MATLAB every time the optimizer is called.

Bilesh Ganguly
  • 3,792
  • 3
  • 36
  • 58
Yousef Hindy
  • 73
  • 1
  • 1
  • 6
  • the question is a little broad.. what is the matlab data you want to run?? – ΦXocę 웃 Пepeúpa ツ Jul 13 '16 at 17:27
  • I have a script that takes in two inputs (times) and returns 2 cell arrays. When in MATLAB, I run it by saying file_name(arg1, arg2), and if I could call the script just like any other function in Java that would be great. I will save the output of the MATLAB script into a file and read it into Java. – Yousef Hindy Jul 13 '16 at 17:38

1 Answers1

2

If you do not want to start up the Matlab application each time you want to run a matlab function then you can use the MCR (matlab compiler runtime). The MCR, once installed in your computer can be accessed by the Matlab Java API on demand.

debopam
  • 51
  • 3