I have this script:
function [ G ] = evalF( F,x,n )
G=zeros(n,1);
xcell = num2cell(x);
for i=1:n
f = F(i)
a = f(xcell{:})
end
end
and these two variables defined:
F =
@(x1,x2)6+2*x1^1+3*x2^2 @(x1,x2)3+3*x1^1+2*x2^2
x =
1 2
and when I run it like this:
evalF(F,x,2)
but I get the error:
Index exceeds matrix dimensions.
Error in evalF (line 8)
a = f(x{:})
I don't see what's wrong... Can anyone help?
I turn an array into arguments, more info about that is here How to split an array as argument values in matlab?