4 Unknowns in 4 trig equations.
5 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
trying to solve these equations simultaniously. Tried using fsolve, but didn't get anywhere. Using the solve function I get 4 solutions for each variable. How do I identify the "correct one" since my initial conditions have already been entered.
Any better way to go about this?
%Initial conditions @ time=0
syms A1 A2 phi1 phi2
E1= A1*Mode1vector(1)*sin(phi1) + A2*Mode2vector(1)*sin(phi2) -x0(1) == 0;
E2= A1*Mode1vector(2)*sin(phi1)+ A2*Mode2vector(2)*sin(phi2) == 0;
E3= A1*W(1)*Mode1vector(1)*cos(phi1) + A2*W(2)*Mode2vector(1)*cos(phi2) == 0;
E4= A1*W(1)*Mode1vector(2)*cos(phi1) +A2*W(2)*Mode2vector(2)*cos(phi2) == 0;
[A1,A2,phi1,phi2]=solve(E1,E2,E3,E4,A1,A2,phi1,phi2)
Result:
A1 =
-1/2
1/2
-1/2
1/2
A2 =
-1/2
-1/2
1/2
1/2
phi1 =
-pi/2
pi/2
-pi/2
pi/2
phi2 =
-pi/2
-pi/2
pi/2
pi/2
0 件のコメント
採用された回答
Prabhan Purwar
2019 年 9 月 17 日
Hi,
Instead of returning an infinite set of periodic solutions for the simultaneous trigonometric equations, the solver picks three solutions that it considers to be the most practical. Set the Principal Value parameter to be true in order to get only principal solutions, as shown.
S1= solve(eqn,x,'PrincipalValue',true)
Alternatively, determine the solution to simultaneous equations by imposing initial conditions and restrictions upon the phi1 and phi2 values, thus enabling selection of particular phi values by adjusting parameters, as illustrated in the following code:
clc
clear all
close all
%Initial conditions @ time=0
syms A1 A2 phi1 phi2
E1= A1*2*sin(phi1) + A2*3*sin(phi2) - 3 == 0;
E2= A1*4*sin(phi1)+ A2*5*sin(phi2) == 0;
E3= A1*2*cos(phi1) + A2*3*cos(phi2) == 0;
E4= A1*4*cos(phi1) +A2*5*cos(phi2) == 0;
eqns=[A1*2*sin(phi1) + A2*3*sin(phi2) - 3 == 0, A1*4*sin(phi1)+ A2*5*sin(phi2) == 0, A1*2*cos(phi1) + A2*3*cos(phi2) == 0, A1*4*cos(phi1) +A2*5*cos(phi2) == 0];
%All solutions
%[A1,A2,phi1,phi2]=solve(eqns,[A1,A2,phi1,phi2]) %(Normal Solution)
%(Principal Values)
%[A1,A2,phi1,phi2]=solve(eqns,[A1,A2,phi1,phi2],'PrincipalValue',true);
[A1,A2,phi1,phi2,parameters,conditions]=solve(eqns,[A1,A2,phi1,phi2],'ReturnConditions',true);
%[solx,parameters,conditions]=solve(E1,A1,'ReturnConditions',true)
% Initial Condition and restriction upon phi
assume(conditions);
restriction = [phi1 > 0];
solk=solve(restriction,parameters);
Please refer to the following link for further information https://www.mathworks.com/help/symbolic/solve.html?searchHighlight=solve&s_tid=doc_srchtitle
Hope this helps.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!