MATLAB Answers

Solving System of 4 Non-Linear Equations

1 view (last 30 days)
Matlab12345
Matlab12345 on 17 Apr 2020
Edited: Stephan on 17 Apr 2020
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

Sign in to comment.

Accepted Answer

Stephan
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

Sign in to comment.

More Answers (0)