How can I solve 4 simultaneous equations ?

5 views (last 30 days)
syms Rcon;
syms Ccon;
syms Rbulk;
syms Cbulk;
w1=6280;
w2=62800;
seta(2,2)=-88.8000;
seta(2,3)=-88.9600;
z(2,2)=213000;
z(2,3)=21800;
solveRcon=1;
solveCcon=1;
solveRbulk=1;
solveCbulk=1;
epns = [ tand(seta(2,2)) + (Rcon + Rbulk)/(1/(w1*Ccon) + 1/(w1*Cbulk)) == 0 , tand(seta(2,3)) + (Rcon + Rbulk)/(1/(w2*Ccon) + 1/(w2*Cbulk)) == 0, abs(z(2,2)) - 1/(sqrt((1/Rcon)^2 +(w1*Ccon)^2)) - 1/(sqrt((1/Rbulk)^2 +(w1*Cbulk)^2)) == 0, abs(z(2,3)) - 1/(sqrt((1/Rcon)^2 +(w2*Ccon)^2)) - 1/(sqrt((1/Rbulk)^2 +(w2*Cbulk)^2)) == 0];
vars = [ Ccon Rcon Cbulk Rbulk ];
[solCcon, solRcon, solCbulk, solRbulk] = solve(epns,vars)
i want to solve 4 simltaneous equation and get 4 syms values( Ccon, Rcon, Cbulk, Rbulk)
but i just get 0x1 sym in Ccon, Rcon, Cbulk, Rbulk

Accepted Answer

Torsten
Torsten on 29 Sep 2022
Edited: Torsten on 29 Sep 2022
You might want to test fsolve and lsqnonlin with different initial guesses for the parameters,
but I doubt you will find a solution.
w1=6280;
w2=62800;
seta(2,2)=-88.8000;
seta(2,3)=-88.9600;
z(2,2)=213000;
z(2,3)=21800;
epns = @(Ccon ,Rcon, Cbulk, Rbulk)[ tand(seta(2,2)) + (Rcon + Rbulk)/(1/(w1*Ccon) + 1/(w1*Cbulk)) , tand(seta(2,3)) + (Rcon + Rbulk)/(1/(w2*Ccon) + 1/(w2*Cbulk)) , abs(z(2,2)) - 1/(sqrt((1/Rcon)^2 +(w1*Ccon)^2)) - 1/(sqrt((1/Rbulk)^2 +(w1*Cbulk)^2)) , abs(z(2,3)) - 1/(sqrt((1/Rcon)^2 +(w2*Ccon)^2)) - 1/(sqrt((1/Rbulk)^2 +(w2*Cbulk)^2)) ];
sol0 = [1 1 1 1];
options = optimset('MaxFunEvals',100000,'MaxIter',100000);
%sol = fsolve(@(x)epns(x(1),x(2),x(3),x(4)),sol0,options)
sol = lsqnonlin(@(x)epns(x(1),x(2),x(3),x(4)),sol0,[],[],options)
Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
sol = 1×4
-0.0019 -0.0560 0.9207 -0.0560
epns(sol(1),sol(2),sol(3),sol(4))
ans = 1×4
1.0e+05 * -0.0005 -0.0004 2.1300 0.2180
  5 Comments
준형 박
준형 박 on 29 Sep 2022
Edited: 준형 박 on 29 Sep 2022
When I ran the code, the same result as what you entered.
'I haven't calculated the unknown.' means I haven't tried calculating this in any other way than matlab.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by