help-octave
[Top][All Lists]
Advanced

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

Re: Basic question: usage of Java methods in Octave


From: Michael Goffioul
Subject: Re: Basic question: usage of Java methods in Octave
Date: Thu, 10 Oct 2013 12:34:10 -0400

On Thu, Oct 10, 2013 at 12:09 PM, <address@hidden> wrote:

Dear all,

 

I'm a newbie in Octave, I just started using the language since I have to do some porting from Matlab .m functions to Octave. Right now I'm stuck with this operation:


import java.lang.Integer;
import java.lang.Float;

xEc_lin = dec2hex(bin2dec(char(Integer.toBinaryString(Float.floatToIntBits(single(DirTvGenData.ec_lin))))),8);
   

I bypassed the import function creating a dummy one (otherwise it gives me a error such as " 'Import' is not a supported function"), since the class should be already active thanks to the Java package installed:

octave:5> v = javaObject ("java.lang.Integer", 12)
v =  12

So it's recognized and it's working when called as Java Object. But the method Integer.toBinaryString is not working:

error: 'Integer' undefined near line 93 column 32
error: evaluating argument list element number 1
error: evaluating argument list element number 1
error: evaluating argument list element number 1

 

So, there's a basic lack in my knowledge of Java methods usage with Octave, which is not happening for sure with Matlab. How can overcome this? Tried to read the manuals, looking for suggestions in half a dozen message boards, but nothing yet.

Thankis in advance to anyone who would be so kind to share his opinions.


The "import" statement is not supported yet by octave, so there's no way you can import java classes into the current scope. To call the static method "toBinaryString" from class "java.lang.Integer", currently you have to use javaMethod:

in Matlab:

import java.lang.Integer;
Integer.toBinaryString(x)

in Octave:

javaMethod('toBinaryString', 'java.lang.Integer', x)

Michael.


reply via email to

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