help-octave
[Top][All Lists]
Advanced

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

[Solved] Re: Problem with arrayfun and parameter dimensions


From: Christoph Mahnke
Subject: [Solved] Re: Problem with arrayfun and parameter dimensions
Date: Fri, 07 Oct 2011 18:00:21 +0200

        John W. Eaton wrote: 
> 
> Do you want to apply the function for each value of X with the
> parameters fixed for each value of X?  If so, then I think you want
> something like
> 
>   X = ...;
>   parameter1 = ...;
>   parameter2 = ...;
>   arrayfun (@(X) dummyfunction (X, parameter1, parameter2), X);
> 
> When the anonymous function
> 
>   @(X) dummyfunction (X, parameter1, parameter2)
> 
> is constructed, parameter1 and parameter2 are set from the context in
> which the anonymous function is constructed.
> 
> But if I understand correctly, your particular problem would probably
> solved more efficiently by writing
> 
>   X * (parameter1 - sum (1 ./ parameter2))
> 
> jwe


Thank you, this was _exactly_ the thing i was looking for.   :-)
The dummyfunction was only an example, because the function for my
application case is quite big and maybe confusing if the context is not
known. But it works for it as well.

I wasn't aware of the fact that the method with anonymous functions can
be so useful. 

Christoph



reply via email to

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