help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing an array from java to octave


From: Kim Hansen
Subject: Re: Passing an array from java to octave
Date: Sun, 22 Nov 2009 13:20:20 +0100

2009/11/2 George Kousiouris <address@hidden>:
> Hi all,
>
> I want to pass a Java array to Octave, so that I can process the data
> inside. Does anyone have an idea how this can be done? I have tried a
> java to octave bridge (javaoctave-0.4.0.jar) however this seems to be
> only for executing Octave commands inside a Java program and not
> actually passing data from Java to Octave...

JavaOctave can transfer many different types of data between Java and Octave.

In the following simple example "a" is a 2x2 matrix that is passed
from Java to Octave and "b" is pulled out of Octave.

The example is from:
http://kenai.com/projects/javaoctave/pages/SimpleExampleOfJavaOctaveUsage
==============
 final OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
 final OctaveMatrix a = new OctaveMatrix(new double[] { 1, 2, 3, 4 }, 2, 2);
 octave.put("a", a);
 final String func = "" //
         + "function res = my_func(a)\n" //
         + " res = 2 * a;\n" //
         + "endfunction\n" //
         + "";
 octave.eval(func);
 octave.eval("b = my_func(a);");
 final OctaveMatrix b = octave.get("b");
 octave.close();
==============

-- 
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437  --  Mobil: 3091 2437



reply via email to

[Prev in Thread] Current Thread [Next in Thread]