Solving trigonometric equations as a optimization problems
Afficher commentaires plus anciens
k12,k13,k23,k11,k22,k33 are constant and equal
P1a = 400; P2a = -200;P3a = -200;Q1a = 193;Q2a = 96.86;Q3a = -96.86;
P1d = (k12.*cos(x(1)*pi/360).*cos(x(2)*pi/360).*sin(x(4)*pi/180))+(k13.*cos(x(1)*pi/360).*cos(x(3)*pi/360).*sin(x(5)*pi/180))
P2d = -(k12.*cos(x(1)*pi/360).*cos(x(2)*pi/360).*sin(x(4)*pi/180))+(k23.*cos(x(2)*pi/360).*cos(x(3)*pi/360).*sin((x(5)-x(4))*pi/180))
P3d = -(k13.*cos(x(1)*pi/360).*cos(x(3)*pi/360).*sin(x(5)*pi/180))+(k23.*cos(x(2)*pi/360).*cos(x(3)*pi/360).*sin((x(4)-x(5))*pi/180))
Q1d = (k11.*cos(x(1)*pi/360).*cos(x(1)*pi/360))-(k12.*cos(x(1)*pi/360).*cos(x(2)*pi/360).*cos(x(4)*pi/180))-(k13.*cos(x(1)*pi/360).*cos(x(3)*pi/360).*cos(x(5)*pi/180))
Q2d = -(k12.*cos(x(1)*pi/360).*cos(x(2)*pi/360).*cos(x(4)*pi/180))+(k22.*cos(x(2)*pi/360).*cos(x(2)*pi/360))-(k23.*cos(x(2)*pi/360).*cos(x(3)*pi/360).*cos((x(5)-x(4))*pi/180))
Q3d = -(k13.*cos(x(1)*pi/360).*cos(x(3)*pi/360).*cos(x(5)*pi/180))-(k23.*cos(x(2)*pi/360).*cos(x(3)*pi/360).*cos((x(5)-x(4))*pi/180))+(k33.*cos(x(3)*pi/360).*cos(x(3)*pi/360))
delP1 = (P1d - P1a);
delP2 = (P2d - P2a);
delP3 = (P3d - P3a);
delQ1 = (Q1d - Q1a);
delQ2 = (Q2d - Q2a);
delQ3 = (Q3d - Q3a);
fcost = (((delP1).^2)+((delP2).^2)+((delP3).^2)+((delQ1).^2)+((delQ2).^2)+((delQ3).^2))
the equality constraints: the angles may vary between -180 degree to 180 degree x=fmincon(@cuptpc,x0,a,b)
Hi all, I was trying to solve a set of trigonometric equations taking as a optimization problems to find five unknown variables i.e. angles x(1), x(2), x(3), x(4), x(5). The actual P and Q values are given. The objective is to search for the angles x(1), x(2), x(3), x(4), x(5) that will minimize the cost function by minimizing the Q values. I am getting like this
fcost = 572.8147
x =
-0.0000 28.2228 71.3840 27.8753 29.6215
I am not sure this is the optimum solution for angles or not. I think the cost function should be much smaller than what I am getting. Could anyone please help me with this? Is there any other methods that can be used to solve these equations?
9 commentaires
Torsten
le 14 Mai 2018
Shouldn't the arguments in your trigonometric terms be x(i)*pi/180 instead of x(i)*pi/360 ?
Mukul
le 14 Mai 2018
Mukul
le 15 Mai 2018
Torsten
le 15 Mai 2018
There is no error from the solver - so what shall we do ?
The only thing that comes to mind is to vary the initial guesses for the solution or/and to try a different solver (e.g. fminsearch or lsqnonlin).
Best wishes
Torsten.
Torsten
le 16 Mai 2018
When using lsqnonlin, you have to return delP1, delP2, delP3, delQ1, delQ2 and delQ3 in "cuptpc", not fcost. Did you do that ?
Mukul
le 16 Mai 2018
Mukul
le 17 Mai 2018
Torsten
le 17 Mai 2018
I've moved my last comment to an answer you can accept.
Best wishes
Torsten.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Choose a Solver dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!