I have these two vectors that are the 2nd and zero order coefficients:
R = [0.0068 0.0036 0.000299 0.0151];
H = [0.0086 0.00453 0.0016 0.00872];
For the equation:
func = @(x) (R - (x * x) * H);
My first question is how can I index each of the elements in the equation such that I have something like this:
func = @(x) (R(i) - (x(j) * x(k)) * H(l))
So for one index, the equation would be (with many roots):
f1 = @(x) 0.0068 - (x(2)*x(3) * 0.00872);
So writing all the equations, and using quadratic optimization for the simultaneous equations, the roots can be found.
But obviously this function handle would not work when indexing is needed. Is there any way to express the equation so that even the independent variable can be indexed? I know there is a way to index other components than the independent such:
f = sprintf('@(x) %f- (x*x)*%f;', R(i), H(i));
But I'm looking to index the variables too so that I can finally get the minimum roots of this quadratic equation:
(x(j)*x(k)) * H(l) + (x(i)*x(l)) * H(k) + (x(k)*x(j)) * H(j) + (x(l)*x(i)) * H(i) = ...
R(i) + R(j) + R(k) + R(l)
My objective is to find the roots that minimizes the above equation, by having the coefficient of the quadratic equation that run through a loop (H(i) & R(j) are given). There is not speicifc constraint rather than interchanging the indices of the equation elements to conserve the symmetry and momentum.
I tried to use fmincon but I don't know how to assign the indexed function handle into the function and using random intial complex roots, get all the possible roots.
I posted a similar question but I think I was not very clear in my statement.