Need help with Octave/Java

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help with Octave/Java

Walter Grossman
Though "Constants" is an interface and can't be instantiated, the commands below work in Matlab.  I understand that Octave doesn't have an import command as Matlab does so how do I mimic this behavior?  Do I need to create a java object in java that implements the interface?  It would be better if I could do something in octave.

Thanks.

Matlab code:
clear all
>> import org.orekit.utils.*
>> c=Constants.SPEED_OF_LIGHT
c =
   299792458
>>




Reply | Threaded
Open this post in threaded view
|

Re: Need help with Octave/Java

Andreas Weber-6
Am 17.07.2018 um 18:31 schrieb Walter Grossman:
> Though "Constants" is an interface and can't be instantiated, the

Have a look at
https://octave.sourceforge.io/miscellaneous/index.html

pkg -forge install miscellaneous
pkg load miscellaneouso
val, uncertainty, unit] =
physical_constant ("speed of light in vacuum")
val =  299792458
uncertainty = 0
unit = m s^-1

-- Andy


Reply | Threaded
Open this post in threaded view
|

Re: Need help with Octave/Java

Mike Miller-4
In reply to this post by Walter Grossman
On Tue, Jul 17, 2018 at 12:31:23 -0400, Walter Grossman wrote:

> Though "Constants" is an interface and can't be instantiated, the commands
> below work in Matlab.  I understand that Octave doesn't have an import
> command as Matlab does so how do I mimic this behavior?  Do I need to
> create a java object in java that implements the interface?  It would be
> better if I could do something in octave.
>
> Thanks.
>
> Matlab code:
> clear all
> >> import org.orekit.utils.*
> >> c=Constants.SPEED_OF_LIGHT
> c =
>    299792458
> >>
Eventually Octave will support this syntax.

For now, you can use the internal workaround function __java_get__:

    __java_get__ ('org.orekit.utils.Constants', 'SPEED_OF_LIGHT')

--
mike



signature.asc (849 bytes) Download Attachment