help-octave
[Top][All Lists]
Advanced

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

Re: Adding .m into javaoctave


From: astie darmayantie
Subject: Re: Adding .m into javaoctave
Date: Wed, 22 Aug 2012 15:53:25 +0700

Please mind my question about the error i had from load function.
I just know that load was used to data form a file to a variable in octave.
the question is how can i load my own function within javaoctave? for i already put my .m function file inside the octave/image-1.0.15
package. or should i put it on the octave core? thank you

2012/8/22 astie darmayantie <address@hidden>
yes, it already works just now! i might be mistype the code last time and suppose that i had to install the image package everytime i re-compile the program.


well, now the question is.. if it calls my normal installation path, why it could not read my function? as it's located on my image package directory?

and i try to call my function using load like this:

    OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
        octave.eval("pkg load image;");
        octave.eval("load /home/astie/octave/image-1.0.15/mainProg2108.m;");

        octave.eval("i=imread('/home/astie/thesis/octave/maple.png');");
        octave.eval("im=rgb2gray(i);");
        octave.eval("i=i(:,:,1);");

        octave.eval("res=mainProg2108(i);");
        OctaveDouble res = octave.get(OctaveDouble.class, "res");
        octave.close();
        Double result = res.get(1);
        System.out.println(result);

and i got this error :
Exception in thread "main" dk.ange.octave.exception.OctaveEvalException: load: /home/astie/octave/image-1.0.15/mainProg2108.m: inconsistent number of columns near line 2

why is it happening? because i search on the internet, there is someone who experience the same problem, but they have not tell what's causing this problem. thank you


2012/8/22 Martin Helm <address@hidden>
Am 22.08.2012 07:03, schrieb astie darmayantie:
> it said that the image package is not installed. can i install it like
> i do in octave?
> because seems like the javaoctave can not "remember" that i have
> installed the image package, so that i had to "remind" it every time i
> recompile.
>
> and here's my code :
> import dk.ange.octave.OctaveEngine;
> import dk.ange.octave.OctaveEngineFactory;
> import dk.ange.octave.type.OctaveDouble;
>
> public class testOctave {
>
>     public static void main(String[] args){
>         OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
>         octave.eval("i=imread('/home/astie/thesis/octave/maple.png');");
>         octave.eval("pkg install -forge image;");
>         octave.eval("res=mainProg2108(i);");
>         OctaveDouble res = octave.get(OctaveDouble.class, "res");
>         octave.close();
>         Double result = res.get(1);
>         System.out.println(result);
>
>
>     }
>
> }
>
> the mainProg2108 is a function i made. in this case, am i able to
> called it from javaoctave? if yes, where should i put the .m file?
> as in the actual octave i just put it on the directory of image package.
>
>
> Thank you.
>
> regards,
>
>
> astie
javaoctave just calls your normal octave installation, unless you have
two or more of them and it calls the wrong one where no image package is
installed.
You should call

octave.eval("pkg load image"); //works perfectly well for me

instead of the octave.eval("pkg install -forge image;");
If that does not work please add a

octave.eval("pkg list")

and post the full terminal output of a run of your program.




--
Regards,


Astie Darmayantie




--
Regards,


Astie Darmayantie


reply via email to

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