Matlab vs Octave

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

Matlab vs Octave

Bostjan JERKO-3
I have a Matlab m file for GA usage. There is an evaluation function used
in rather strange way (at least for me):

function [val,x]=gaDemo1Eval(x,parameters)
val = x(1) + 10*sin(5*x(1)+7*cos(4*x(2)):

After that, this function is used in ga program:

bxtX= ga([0 10: 0  -10], 'gaDemo1Eval')


It seems to be calling the evaluation function. Does anybody know how to translate that to Octave ?

Regards,
        B.



---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: Matlab vs Octave

Frederic Gobry
> After that, this function is used in ga program:
>
> bxtX= ga([0 10: 0  -10], 'gaDemo1Eval')
>
>
> It seems to be calling the evaluation function. Does anybody know how to
> translate that to Octave ?

So far, nothing special occured, as the parameter to ga () is the name (as a
normal string) of the function. Inside ga () you probably have a feval ()
function. To call a function whose name is stored in funcname, you can write
something like :

function ga (argument, funcname)

feval (funcname, argument);

endfunction


If you have a variable number of additional arguments for the subfunction,
you can try :

function ga (argument1, funcname, ...)

feval (funcname, argument, all_va_args);

endfunction


Then, ga (1, 'gronf', 2, 3) will call gronf (1, 2, 3)

Hope this helps,
Frédéric

--
    Frédéric GOBRY                  IDIAP
                               Rue du Simplon 4,
  Research Assistant          CH 1920 - Martigny
Machine Learning Group      Tel: +41 27 721 77 31



---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------