0
votes

I am writing a program in Matlab and I have a function defined this way.

sum (i=1...100) (a*x(i) + b*y(i) + c)

x and y are known, while a, b and c are not: I need to find values for them such that the total value of the function is minimized. There is no additional constraint for the problem.

I thought of using fminsearch to solve this minimization problem, but from Mathworks I get that functions which are suitable inputs for fminsearch are defined like this (an example):

square = @(x) x.^2

So in my case I could use a vector p=[a, b, c] as the value to minimize, but then I don't know how to define the remaining part of the function. As you can see the number of possible values for the index i is huge, so I cannot simply sum everything together explicitly, but I need to represent the summation in some way. If I write the function somewhere else then I am forced to use symbolic calculus for a, b and c (declaring them with syms) and I'm not sure fminsearch would accept that.

What can I do? Of course if fminsearch turns out to be unfeasible for my situation I accept links to use something else.

1
You want to minimize the pure sum, subject to NO constraints? There is no minimum. My guess is you have a different problem. So why not tell us just a bit more, rather than confusing us?user85109
a = b = c = -inf. done.user85109

1 Answers

1
votes

The most general solution is to use x and y in the definition of the objective function:

>> objfun = @(p) sum( p(1).*x + p(2).*y + p(3) );
>> optp = fminsearch( objfun, po, ... );