How to run Matlab compiled Java function?

I compiled a Matlab script for Java with the Matlab compiler SDK. Everything worked fine. Matlab generated Jar.file and I included it in my Java project in eclipse. Now my problem is that the matlab script contains a complex algorithm function. Now this function can be called in Java. I need to read 10 csv files, each of which contains 10,000 rows with 4 data columns and passes the same arguments to the java function as in matlab.

Like my csv files: 4 columns, 10,000 rows.

a x y z
1 3 4 5
4 4 5 6
. . . .

readsfirst data in a separate function in variables. Also get the length.

[a,x,y,z] = readData(['csv\' files(1).name]);
sizeOfa=length(a);

after I call my algorithm function 3 times with different columns, and also pass the size a.

   algorithm(a,x,sizeOfa);
   algorithm(a,y,sizeOfa);
   algorithm(a,z,sizeOfa);

after that, the definition of my algorithm appears.

function y= algorithm(x,y,sizeofX)
   do some stuff...
   end

Now my question is:

, csv, Matlab 10000 * 1. Java. ? a, x, y, z . 1 * 10000. ? readfile java, .

+4
1

.

MATLAB

Matlab 10000 * 1.

1
2
3
4
..
10000

, , .

1 2 3 4 .. 10000

, , , matlab.

   function y = algorithm(a,z,sizeOfa)
    {
      a=a'; // transpose 
      z=z'; //transpose
       ...
         //your stuff

    }

, java-, .

EDIT:

Java

double[] t;  // your Double Array

int tSize= t.length; // get Size

MWNumericArray result;

result= MWNumericArray.newInstance(new int[]{tSize,1},t,MWClassID.DOUBLE);

, n * 1, n - .

+1

Source: https://habr.com/ru/post/1672021/


All Articles