How to load multiple parameters from Matlab to a Java program

2 views (last 30 days)
Hi,
I am making a Java program that must call some matlab functions. I have received some simple test programs to play with so I can learn how it all works.
My problem is that one of the matlab test programs needs many input parameters. I'd like to load a tab of double in it as input parameters
In my Java program, the throwed error don't help me :
> A fatal error has been detected by the Java Runtime Environment:
> EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000506c79f0, pid=1856, tid=5228
> JRE version: Java(TM) SE Runtime Environment (7.0_55-b13) (build 1.7.0_55-b13)
> Java VM: Java HotSpot(TM) 64-Bit Server VM (24.55-b03 mixed mode windows-amd64 compressed oops)
> Problematic frame:
> V [jvm.dll+0x1279f0]
> Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
> An error report file with more information is saved as:
> C:\Projects\workspacesMyTest\MyTest\hs_err_pid1856.log
> If you would like to submit a bug report, please visit:
> http://bugreport.sun.com/bugreport/crash.jsp
>
Here is the matlab code:
function y = quadratic3(inputParameterValues)
a1 = inputParameterValues(0);
b1 = inputParameterValues(1);
c1 = inputParameterValues(2);
x1 = inputParameterValues(3);
y = (a1.*(x1.^2)) + (b1.*x1) + c1;
Here is the Java method that calls matlab and prints output:
MWNumericArray inTab = null;
Object[] result = null;
Class1 myQuadratic3 = null;
Double[] inParams = new Double[4];
inParams[0] = new Double(1.0);
inParams[1] = new Double(0.0);
inParams[2] = new Double(0.0);
inParams[3] = new Double(9.0);
try
{
inTab = new MWNumericArray(inParams, MWClassID.STRUCT);
myQuadratic3 = new Class1();
result = myQuadratic3.quadratic3(1, inParams);
System.out.println("\n\n -> " + result[0]);
}
catch (Exception e)
{
System.out.println("Exception: " + e.toString());
}
finally
{
System.out.println("finally: ");
MWArray?.disposeArray(inParams);
MWArray?.disposeArray(result);
myQuadratic3?.dispose();
}
What am I doing wrong here?
PS: I have used a MWClassID.STRUCT. Is it a trouble ?

Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!