How to solve a system of equations whose unknowns values are exponents with cole-cole methods
1 次查看(过去 30 天)
显示 更早的评论
I want to solve this equation,
I want to calculate the value of B1,B2
I use this equation
eh = 45.;
kl = 4.15;
de1 = 6200;
fc1 = 500*10^3;
de2 = 990;
fc2 = 2.70*10^6;
b1 = 0.86;
b2=0.98;
f=10^4;
% ev=8.854187817 * 10^(-12);
ev=8.854 * 10^(-12); %pF/m
e0 = eh+de1/(1+j*f/fc1)^b1+de2/(1+j*f/fc2)^b2+kl/(j*2*pi*f*ev)
e1 = real(e0);
e2 = -imag(e0);
%%
x0 = [b1,b2];
% options=optimset('MaxFunEvals',1e4,'MaxIter',1e4);
options = optimoptions('fsolve','Display','iter','TolFun',1e-30,'TolX',1e-30);
[x,FVAL,EXITFLAG,OUTPUT,JACOB] = fsolve(@(x)fun_cole_cole(x,fc1,fc2,f,de1,de2,eh,kl,ev,e1,e2),x0,options);
The fun_cole_cole function is shown below
function f = fun_cole_cole(x,fc1,fc2,f,de1,de2,eh,kl,ev,e1,e2) % b c可以是随意的参数
A1 = fc1^x(1)+f^x(1)*cos(pi*x(1)/2);
A2 = fc2^x(2)+f^x(2)*cos(pi*x(2)/2);
B1 = f^x(1)+sin(pi*x(1)/2);
B2 = f^x(2)+sin(pi*x(2)/2);
D1 = de1*fc1^x(1);
D2 = de2*fc2^x(2);
w = 2*pi*f;
f1 = A1*D1/(A1^2+B1^2)+A2*D2/(A2^2+B2^2)+eh-e1;
f2 = B1*D1/(A1^2+B1^2)+B2*D2/(A2^2+B2^2)+kl/(w*ev)-e2;
f = [f1;f2];
But I got this result
No solution found.
fsolve stopped because the problem appears to be locally singular.
When I set options as
options=optimset('MaxFunEvals',1e4,'MaxIter',1e4);
I got this
No solution found.
fsolve stopped because the relative size of the current step is less than the
default value of the step size tolerance squared, but the vector of function values
is not near zero as measured by the default value of the function tolerance.
0 个评论
采纳的回答
Walter Roberson
2021-3-20
编辑:Walter Roberson
2021-3-20
This reacts well to a standard trick of converting a system of equations into a least-squared minimization.
The fsolve() is not needed; I kept it in to show you that the result of the fmincon() checks out with fmincon()
format long g
eh = 45.;
kl = 4.15;
de1 = 6200;
fc1 = 500*10^3;
de2 = 990;
fc2 = 2.70*10^6;
b1 = 0.86;
b2=0.98;
f=10^4;
% ev=8.854187817 * 10^(-12);
ev=8.854 * 10^(-12); %pF/m
e0 = eh+de1/(1+j*f/fc1)^b1+de2/(1+j*f/fc2)^b2+kl/(j*2*pi*f*ev)
e1 = real(e0);
e2 = -imag(e0);
%%
x0 = [b1,b2];
% options=optimset('MaxFunEvals',1e4,'MaxIter',1e4);
options = optimoptions('fsolve','Display','iter','TolFun',1e-3,'TolX',1e-3);
f = @(x)fun_cole_cole(x,fc1,fc2,f,de1,de2,eh,kl,ev,e1,e2);
syms x [1 2]
residue = sum(f(x).^2);
R = matlabFunction(residue,'vars',{x});
[best, fval] = fmincon(R, x0)
[x,FVAL,EXITFLAG,OUTPUT,JACOB] = fsolve(f,best,options)
function f = fun_cole_cole(x,fc1,fc2,f,de1,de2,eh,kl,ev,e1,e2) % b c可以是随意的参数
A1 = fc1^x(1)+f^x(1)*cos(pi*x(1)/2);
A2 = fc2^x(2)+f^x(2)*cos(pi*x(2)/2);
B1 = f^x(1)+sin(pi*x(1)/2);
B2 = f^x(2)+sin(pi*x(2)/2);
D1 = de1*fc1^x(1);
D2 = de2*fc2^x(2);
w = 2*pi*f;
f1 = A1*D1/(A1^2+B1^2)+A2*D2/(A2^2+B2^2)+eh-e1;
f2 = B1*D1/(A1^2+B1^2)+B2*D2/(A2^2+B2^2)+kl/(w*ev)-e2;
f = [f1;f2];
end
5 个评论
Walter Roberson
2021-3-20
As I wrote, "The fsolve() is not needed; I kept it in to show you that the result of the fmincon() checks out with fmincon()"
fmincon() is a minimizer; it could potentially have returned a value that was not a root, or it might have gotten stuck just a little away from a root. Any time you switch between techniques (I recoded fsolve as fmincon) then at the beginning you want to reassure yourself that the new technique does as well as the old one would have done. Once you have tried a few cases and seen that it does work, you can get rid of the fsolve call.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!