[Top][All Lists]

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

Re: function help

From: Jordi Gutiérrez Hermoso
Subject: Re: function help
Date: Thu, 23 Feb 2012 15:27:40 -0500

On 23 February 2012 15:15, Martin Helm <address@hidden> wrote:
> Am 23.02.2012 20:55, schrieb damian.harty:
>> And then it works. I fail at every attempt to combine them into a
>> single file...
> Because by design all the additional function definitions in the .m file
> are local and hidden to the outside world. You can of course make them
> visible with function handles like this

That's an ugly an unnecessary Matlab-inspired hack.

In Octave, unlike in Matlab, you can define functions in the
interpreter and in script files.

So you can do something like writing this in func_init.m:

    function out = foo(x)
       ## ...

    function out = bar(x)
       ## ...

And whenever you write "func_init" both foo and bar functions will be
defined in scope.

Subfunctions are still hidden like in Matlab, but at least you don't
need to be doing uglier function handle hacks to just get a few
functions into scope.

- Jordi G. H.

reply via email to

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