Solving trigonometric equations as a optimization problems

3 views (last 30 days)
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 Comments
Mukul
Mukul on 17 May 2018
Thank you for your time. I solved it and checked with lsqnonlin and fmincon function that gives the same results for angles.
How can I accept your answer - not getting any options here?
Torsten
Torsten on 17 May 2018
I've moved my last comment to an answer you can accept.
Best wishes
Torsten.

Sign in to comment.

Accepted Answer

Torsten
Torsten on 17 May 2018
function fcost=cuptpc(x)
L = 22.5e-6;
A1 = 40;
A2 = 40;
A3 = 40;
n=1;
f=20e3;
M = 1.0; / ????
A = 1.0; % ????
k11 = (16*A1*A1)/(n^3*(pi)^2*(2*pi*f)*M)
k22 = (16*A2*A2)/(n^3*(pi)^2*(2*pi*f)*M)
k33 = (16*A3*A3)/(n^3*(pi)^2*(2*pi*f)*M)
k12 = (8*A1*A2)/(n^3*(pi)^2*(2*pi*f)*M)
k13 = (8*A1*A3)/(n^3*(pi)^2*(2*pi*f)*M)
k23 = (8*A2*A3)/(n^3*(pi)^2*(2*pi*f)*A)
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 delP2 delP3 delQ1 delQ2 delQ3];
end
and the main program is
lb = [90 90 90 90 90]; % ????
ub = [180 180 180 180 180]; % ????
x0 = [30 40 35 50 50];
x=lsqnonlin(@cuptpc,x0,lb,ub)
Please check the lines with % ???? .
Best wishes
Torsten.

More Answers (0)

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!