4 Unknowns in 4 trig equations.
7 views (last 30 days)
Show older comments
David Botha
on 12 Sep 2019
Answered: Prabhan Purwar
on 17 Sep 2019
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 Comments
Accepted Answer
Prabhan Purwar
on 17 Sep 2019
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 Comments
More Answers (0)
See Also
Categories
Find more on Calculus 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!