Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Creation of a list of functions, multiplying functions and integrating them
Replies: 3   Last Post: Apr 25, 2013 10:48 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,945
Registered: 12/7/04
Re: Creation of a list of functions, multiplying functions and integrating them
Posted: Apr 25, 2013 9:41 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Tot " <najib_cool19@hotmail.com> 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

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.