Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matlab in JAVA or java in MATLAB?

Subject: matlab in JAVA or java in MATLAB?

From: Lemon F

Date: 3 Aug, 2010 13:09:04

Message: 1 of 3

Hi guys

I am now experencing a great difficulty in the interation between java and matlab.

I have an objective function written in JAVA with has method return an numerical number, i call it 'profit'. The nature of this obtive function (ObjFun.java) is that it takes an parameter input, say C, with different C value, the returned profit value is different.

Eventually I want to find the optimized C value which produce the maximun profit (C will be under constrains). Initially I want to use linprog or fminsearch in matlab. So I tried the command in matlab that excutes my ObjFun.java. But it failed because my ObjFun.java will call an external .exe file. and the file path contains spaces which is fine by Java but not matlab.

I stuck here, I myself is a Java programmer not good at matlab, I can't find any thing on google about the solution to my problem. So here I propose another idea: call matlab function in JAVA.

I need some advise on this. Thank you very much for a reply!!!

Lemon

Subject: matlab in JAVA or java in MATLAB?

From: Yair Altman

Date: 3 Aug, 2010 17:01:04

Message: 2 of 3

"Lemon F" <f.lemon.jin@hotmail.com> wrote in message <i394dg$3n8$1@fred.mathworks.com>...
> Hi guys
>
> I am now experencing a great difficulty in the interation between java and matlab.
>
> I have an objective function written in JAVA with has method return an numerical number, i call it 'profit'. The nature of this obtive function (ObjFun.java) is that it takes an parameter input, say C, with different C value, the returned profit value is different.
>
> Eventually I want to find the optimized C value which produce the maximun profit (C will be under constrains). Initially I want to use linprog or fminsearch in matlab. So I tried the command in matlab that excutes my ObjFun.java. But it failed because my ObjFun.java will call an external .exe file. and the file path contains spaces which is fine by Java but not matlab.
>
> I stuck here, I myself is a Java programmer not good at matlab, I can't find any thing on google about the solution to my problem. So here I propose another idea: call matlab function in JAVA.
>
> I need some advise on this. Thank you very much for a reply!!!
>
> Lemon


Calling Matlab from Java is undocumented and unsupported. There are several ways you can do this. Here are two links to get you started:

http://UndocumentedMatlab.com/blog/jmi-wrapper-remote-matlabcontrol/
http://code.google.com/p/matlabcontrol/

Yair Altman
http://UndocumentedMatlab.com

Subject: matlab in JAVA or java in MATLAB?

From: Lemon F

Date: 5 Aug, 2010 09:30:25

Message: 3 of 3

Thank you so much for you help, information provided are helpful, and I found a solution using matlab builder ja. which converts matlab codes(inc. matlab lib function) into java library.

Sry for the double post...didn't realise that.

Cheers

Lemon

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us