Solving System of 4 Non-Linear Equations
30 views (last 30 days)
Show older comments
I have a system of four non-linear equations with four unknowns as have tried coding it as follows:
syms A B t0 C
eq1 = A*sin(2*B*3.1416*0.2 + 2*B*3.1416*(0 - t0)^2)+C - sin(2*3.1416*0.2)
eq2 = A*sin(2*B*3.1416*0.4 + 2*B*3.1416*(0 - t0)^2)+C - sin(2*3.1416*0.4)
eq3 = A*sin(2*B*3.1416*0.5 + 2*B*3.1416*(0 - t0)^2)+C - sin(2*3.1416*0.5)
eq4 = A*sin(2*B*3.1416*0.7 + 2*B*3.1416*(-t0)^2)+C - sin(2*3.1416*0.7)
sol = fsolve(eq1,eq2,eq3,eq4);
sol.xo
However, I get an error saying that fsolve requires the input x0 to be of data type double. How would I obtain the solution of this system using commands that do not require additional toolboxes?
0 Comments
Accepted Answer
Stephan
on 17 Apr 2020
Edited: Stephan
on 17 Apr 2020
fsolve is a numerical solver - use vpasolve instead:
syms A B C t0
eq1 = A*sin(2*B*pi*0.2 + 2*B*pi*(0 - t0)^2)+C - sin(2*pi*0.2);
eq2 = A*sin(2*B*pi*0.4 + 2*B*pi*(0 - t0)^2)+C - sin(2*pi*0.4);
eq3 = A*sin(2*B*pi*0.5 + 2*B*pi*(0 - t0)^2)+C - sin(2*pi*0.5);
eq4 = A*sin(2*B*pi*0.7 + 2*B*pi*(-t0)^2)+C - sin(2*pi*0.7);
result = vpasolve([eq1,eq2,eq3,eq4]);
A = result.A
B = result.B
C = result.C
t0 = result.t0
I allowed myself to replace 3.1416 by pi
0 Comments
More Answers (0)
See Also
Categories
Find more on Power and Energy Systems 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!