Date: Apr 25, 2013 9:41 AM
Author: Steven Lord
Subject: Re: Creation of a list of functions, multiplying functions and integrating them

"Tot " <> wrote in message
> Ok It's me again.
> I managed to multiply and integrate function handles as I wanted to.
> Now can anyone help me to create a list (or array) of function handle A,
> so that i can write something like:
> for i=1:n
> A(i)=@(x) blablabla(x)
> end
> Does anybody have an idea?

MATLAB no longer allow creation of arrays of function handles. You will need
to create a cell array.

S = {@sin, @(x) x.^2, @exp};
f = @(x) S{1}(x).*S{2}(x)-S{3}(x);
result1 = f(0.2)

% Alternately to get a cell array of values of the functions in S
g = @(x) cellfun(@(myfun) myfun(x), S, 'UniformOutput', false);
h = g(0:0.1:1)
h{1} % sin(0:0.1:1)
result2 = h{1}(3)*h{2}(3)-h{3}(3)

Steve Lord
To contact Technical Support use the Contact Us link on