I want to find the five unknown of a system of five nonlinear equations. Thank you !
1 次查看(过去 30 天)
显示 更早的评论
Here the code:
clc;
clear;
close all;
clearvars;
syms ET i1 i2 i3 i4 i5 x1 x2 x3 x4 x5 % constants defined below
syms k1 k2 k3 k4 k7 % unknown variables
ET=1
i1=0.2
i2=0.32
i3=0.43
i4=0.3
i5=0.15
x1=100
x2=200
x3=400
x4=600
x5=800
eq1 = 0==-i1+k7*k3/(k4+k7)*(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1))*(ET-(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1)))/(1+2*k3/(k4+k7)*(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1)));
eq2 = 0==-i2+k7*k3/(k4+k7)*(-(k2+k1*x2-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x2-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x2+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x2))*(ET-(-(k2+k1*x2-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x2-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x2+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x2)))/(1+2*k3/(k4+k7)*(-(k2+k1*x2-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x2-k7*k3/(k4+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/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5))*(ET-(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5)))/(1+2*k3/(k4+k7)*(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5)));
eq1=subs(eq1); eq2=subs(eq2); eq3=subs(eq3); eq4=subs(eq4); eq5=subs(eq5);
[k1,k2,k3,k4,k7]=fsolve( [eq1, eq2, eq3, eq4, eq5], [k1,k2,k3,k4,k7])
0 个评论
回答(1 个)
Torsten
2022-1-13
编辑:Torsten
2022-1-13
function main
x0 = rand(5,1);
x = fsolve(@fun,x0)
end
function res = fun(x)
k1 = x(1);
k2 = x(2);
k3 = x(3);
k4 = x(4);
k7 = x(5);
ET=1;
i1=0.2;
i2=0.32;
i3=0.43;
i4=0.3;
i5=0.15;
x1=100;
x2=200;
x3=400;
x4=600;
x5=800;
res(1) = -i1+k7*k3/(k4+k7)*(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3 /(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1))*(ET-(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1)))/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k4+k7)*(k7+2*k1*x3)));
res(4) = -i4+k7*k3/(k4+k7)*(-(k2+k1*x4-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x4-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x4+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x4))*(ET-(-(k2+k1*x4-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x4-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x4+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x4)))/(1+2*k3/(k4+k7)*(-(k2+k1*x4-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x4-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x4+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x4)));
res(5) = -i5+k7*k3/(k4+k7)*(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5))*(ET-(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5)))/(1+2*k3/(k4+k7)*(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5)));
end
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!