4 equation 2 solution

2 views (last 30 days)
onur karakurt
onur karakurt on 30 Sep 2023
Commented: Star Strider on 30 Sep 2023
How can I find two variables from 4 equation, All equation are equal zero. I want fo find Theta_1 and Theta_2. These values are positive and Theta_2 must bigger than Theta_1. Initial value of Theta_1 will find with below solution.
u=deg2rad(15);
hd=24.5395;
R1_p =32.0080;
R2_p =48.0120;
eqn= @(t1, u) u+atan(sin(t1)./(1-cos(t1)))-pi/2 % theta1 t1 olarak tanımlanmıştır.
Theta_1_initial= (fminsearch(@(t1)norm(eqn(t1, u)),u))
Can Anybody help me ? What is the solution to find Theta_2 and Theta_1
eqn1= @ (Theta_2, Theta_1, u) cos(Theta_2)+sin(Theta_2)*tan(Alpha)-cos(Theta_1)-sin(Theta_1)*tan(u)
eqn2 =@ (R1_p, Phi, L3, Alpha, hd) R1_p-R1_p*cos(Phi)-L3*sin(Alpha+Phi)+hd
Phi = @( R1_p, R2_p, Theta_2, Theta_1, Alpha) atan(R2_p*(Theta_2-Theta_1)/(R1_p-R2_p*(Theta_2-Theta_1)*tan(Alpha)))
Alpha =@( Theta_1, Theta_2, u) pi/2-atan(sin(Theta_2)/(cos(Theta_1)+sin(Theta_1)*tan(u)-cos(Theta_2)))

Accepted Answer

Star Strider
Star Strider on 30 Sep 2023
Since ‘Phi’ and ‘L3’ are not defined, I created them (and ‘Alpha’) as parameters to be estimated hiere.
I am not certain what you are doing, however this produces estimates for the parameters —
u=deg2rad(15);
hd=24.5395;
R1_p =32.0080;
R2_p =48.0120;
% eqn1= @ (Theta_2, Theta_1, u) cos(Theta_2)+sin(Theta_2)*tan(Alpha)-cos(Theta_1)-sin(Theta_1)*tan(u)
% eqn2 =@ (R1_p, Phi, L3, Alpha, hd) R1_p-R1_p*cos(Phi)-L3*sin(Alpha+Phi)+hd
% Phi = @( R1_p, R2_p, Theta_2, Theta_1, Alpha) atan(R2_p*(Theta_2-Theta_1)/(R1_p-R2_p*(Theta_2-Theta_1)*tan(Alpha)))
% Alpha =@( Theta_1, Theta_2, u) pi/2-atan(sin(Theta_2)/(cos(Theta_1)+sin(Theta_1)*tan(u)-cos(Theta_2)))
eqn= @(t1, u) u+atan(sin(t1)./(1-cos(t1)))-pi/2 % theta1 t1 olarak tanımlanmıştır.
eqn = function_handle with value:
@(t1,u)u+atan(sin(t1)./(1-cos(t1)))-pi/2
Theta_1_initial= (fminsearch(@(t1)norm(eqn(t1, u)),u))
Theta_1_initial = 0.5236
fcn = @(Theta_1, Theta_2, u, Alpha, Phi, L3) [cos(Theta_2)+sin(Theta_2)*tan(Alpha)-cos(Theta_1)-sin(Theta_1)*tan(u)
R1_p-R1_p*cos(Phi)-L3*sin(Alpha+Phi)+hd
atan(R2_p*(Theta_2-Theta_1)/(R1_p-R2_p*(Theta_2-Theta_1)*tan(Alpha)))
pi/2-atan(sin(Theta_2)/(cos(Theta_1)+sin(Theta_1)*tan(u)-cos(Theta_2)))];
B = fminsearch(@(b) norm(fcn(b(1),b(2),u,b(3),b(4),b(5))), [Theta_1_initial; rand(4,1)]);
Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. Current function value: 0.502807
fprintf(1,'Theta_1 = %8.4f\nTheta_2 = %8.4f\nAlpha = %8.4f\nPhi = %8.4f\nL3 = %8.4f\n',B)
Theta_1 = -3.1298 Theta_2 = -9.3933 Alpha = 1.0667 Phi = 1.1600 L3 = 55.3248
.
  2 Comments
onur karakurt
onur karakurt on 30 Sep 2023
all function are depend on Theta_2 and Theta_1, I am triying to find positive optimum values of these.
Star Strider
Star Strider on 30 Sep 2023
If you want to constrain ghtm to be positive, use the lsqcurvefit function or fmincon function (that will work with your current code and allows parameter constraints). Both require the Optimization Toolbox.
Using fmincon
u=deg2rad(15);
hd=24.5395;
R1_p =32.0080;
R2_p =48.0120;
eqn= @(t1, u) u+atan(sin(t1)./(1-cos(t1)))-pi/2; % theta1 t1 olarak tanımlanmıştır.
Theta_1_initial= (fminsearch(@(t1)norm(eqn(t1, u)),u))
Theta_1_initial = 0.5236
fcn = @(Theta_1, Theta_2, u, Alpha, Phi, L3) [cos(Theta_2)+sin(Theta_2)*tan(Alpha)-cos(Theta_1)-sin(Theta_1)*tan(u)
R1_p-R1_p*cos(Phi)-L3*sin(Alpha+Phi)+hd
atan(R2_p*(Theta_2-Theta_1)/(R1_p-R2_p*(Theta_2-Theta_1)*tan(Alpha)))
pi/2-atan(sin(Theta_2)/(cos(Theta_1)+sin(Theta_1)*tan(u)-cos(Theta_2)))];
B = fmincon(@(b) norm(fcn(b(1),b(2),u,b(3),b(4),b(5))), [Theta_1_initial; rand(4,1)], [],[],[],[],[0 0 -Inf -Inf -Inf]);
Local minimum possible. Constraints satisfied. fmincon stopped because the size of the current step is less than the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
fprintf(1,'Theta_1 = %8.4f\nTheta_2 = %8.4f\nAlpha = %8.4f\nPhi = %8.4f\nL3 = %8.4f\n',B)
Theta_1 = 3.1416 Theta_2 = 3.1401 Alpha = 0.6511 Phi = 1.0115 L3 = 39.7306
Here, I simply bounded the first two parameters (‘Theta_1’, ‘Theta_2’) to be and let the others range freely. See the fmincon documentation that I linked to, to constrain the other parameters if necessary.
If you have values for ‘Phi’ and ‘L3’, use those values instead of estimating them. Then make appropriate changes to ‘fcn’ and the call to it in fmincon.
The parameter estimates are not reproducable between code runs. Different runs produce different results, although that might improve (stabilise) if you have values for ‘Phi’ and ‘L3’.
.

Sign in to comment.

More Answers (0)

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!