help-octave
[Top][All Lists]
Advanced

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

How to bind a function argument


From: John W. Eaton
Subject: How to bind a function argument
Date: Tue, 13 Jun 2006 10:26:00 -0400

On 13-Jun-2006, Gregor Beck wrote:

| Hi,
| 
| I try to bind a function argument e.g. 
| 
| fun1 = @(x) fun2(x,a)
| 
| This seams to work with matlab but fails with octave up to version 2.9.5
| 
| The only way I found to achieve something similar is to use a global variable:
| 
| global very_long_and_ugly_name_for_a;
| function y = fun1(x)
|   global very_long_and_ugly_name_for_a;
|    y = fun2(x,  very_long_and_ugly_name_for_a);
| end
| 
| Is there another way to do this?
| Is it possible to expand the scope of a variable to anonymous or nested 
| functions to avoid the global?

This is a known problem.  The feature you are requesting is a
relatively recent addition to Matlab, and a significant departure from
previous scoping rules.  Fixing this problem is on the long list of
other things that would be nice to fix.

If you would like to help, patches are welcome.

This topic should go in the FAQ.

jwe


reply via email to

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