I needed to parameterise your V equation for it to work with the Optimization Toolbox routines:
V = @(p) -(26*(2000*cos((pi*p(1))/180) + (sin((pi*(p(1) + 45))/180)*((2600000*cos((pi*(p(1) + p(2)))/180)*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180)))/(cos((pi*p(1))/180)^2*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180))) + (2600000*cos((pi*p(1))/180)*sin((pi*(p(1) + 45))/180))/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180)))))/((1300*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180))^2)/cos((pi*p(1))/180)^3 + (1300*sin((pi*(p(1) + 45))/180)^2)/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)^2) + 8085710131136235/4398046511104)))/(3*cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)) - (26*((2^(1/2)*((2600000*cos((pi*(p(1) + p(2)))/180)*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180)))/(cos((pi*p(1))/180)^2*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180))) + (2600000*cos((pi*p(1))/180)*sin((pi*(p(1) + 45))/180))/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180)))))/(2*((1300*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180))^2)/cos((pi*p(1))/180)^3 + (1300*sin((pi*(p(1) + 45))/180)^2)/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)^2) + 8085710131136235/4398046511104)) + (cos((pi*(p(1) + p(2)))/180)*(2000*cos((pi*p(1))/180) + (sin((pi*(p(1) + 45))/180)*((2600000*cos((pi*(p(1) + p(2)))/180)*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180)))/(cos((pi*p(1))/180)^2*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180))) + (2600000*cos((pi*p(1))/180)*sin((pi*(p(1) + 45))/180))/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180)))))/((1300*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180))^2)/cos((pi*p(1))/180)^3 + (1300*sin((pi*(p(1) + 45))/180)^2)/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)^2) + 8085710131136235/4398046511104)))/sin((pi*p(2))/180)))/(3*cos((pi*p(1))/180)^2) - (539047342075749*((2600000*cos((pi*(p(1) + p(2)))/180)*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180)))/(cos((pi*p(1))/180)^2*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180))) + (2600000*cos((pi*p(1))/180)*sin((pi*(p(1) + 45))/180))/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180)))))/(43980465111040*((1300*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180))^2)/cos((pi*p(1))/180)^3 + (1300*sin((pi*(p(1) + 45))/180)^2)/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)^2) + 8085710131136235/4398046511104));
Since you want to optimise it and the Optimization Toolbox functions minimise it, negating it produced a maximum. (That explains the minus sign.)
The code for the optimisation is:
A = [1 1];
b = 90;
[angs, fval] = fmincon(V, [1 1]', A, b)
asum = angs(1) + angs(2)
The A and b arguments are the equivalent of: (a + b) <= 90. The asum statement simply checks to see that the constraint was met.
The optimisation results are:
angs =
-93.3393e+000
180.0000e+000
fval =
-694.1977e+009
asum =
86.6607e+000
I negated V to get the maximum, so in reality fval = 694.1977e+009.
Since the solver uses the Jacobian to find the minimum of the function and reported:
Local minimum possible. Constraints satisfied.
fmincon stopped because the size of the current step is less than
the default value of the step size tolerance and constraints are
satisfied to within the default value of the constraint tolerance.
the constraints on the derivatives were satisfied automatically.
Best Answer