It is required to set a vector consisting of functions, for example:

g = @(x, y) x.^2 + y.^2; f = @(x, y) x.^3 + y.^4; 

It is assumed that the function g can be accessed through a call to an element of the vector. So that you can specify the vector of functions as a parameter to any user-defined function. How to write this in Matlab?

    2 answers 2

     F(1) = {@(x) x.^3-43}; F(2) = {@(x) x*exp(-x.^4)}; F(3) = {@(x) cos(x)}; f = F{1} % лежит первая функция x = 1; f(x) 

    An example of a code showing a vector of functions

      Try to use not a vector, but an array of cells {@fun1, @fun2, ..., @funN} .

       funarray = {@(x) x.^3-43, @(x) x*exp(-x.^4), @(x) cos(x)}; funarray{1}(1); ans = -42