4 equation 2 solution
조회 수: 2 (최근 30일)
이전 댓글 표시
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)))
댓글 수: 0
채택된 답변
Star Strider
2023년 9월 30일
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.
Theta_1_initial= (fminsearch(@(t1)norm(eqn(t1, u)),u))
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)]);
fprintf(1,'Theta_1 = %8.4f\nTheta_2 = %8.4f\nAlpha = %8.4f\nPhi = %8.4f\nL3 = %8.4f\n',B)
.
댓글 수: 2
Star Strider
2023년 9월 30일
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))
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]);
fprintf(1,'Theta_1 = %8.4f\nTheta_2 = %8.4f\nAlpha = %8.4f\nPhi = %8.4f\nL3 = %8.4f\n',B)
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’.
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!