Hi there, I would like to create functions and then sum them up in a loop. Then use an optimizer to find the minimum of the summation. The functions are the same but I need them to have independent variables.
for example: I need a "matrix" of functions
A=[@(x)(x(1)-S(1))^2, @(x)(x(2)-S(2))^2,..., @(x)(x(n)-S(n))^2]
,where S a (1xn) matrix. Then summing all of the above functions to get the minimum
x0 = [0,0,...n];x = fminsearch(sum(A(:)),x0)
The above code does not work but I am just posting it so you get a better idea of what I am looking for. Thank you
Best Answer