Error fsolve undefined function or variable x.
3 次查看(过去 30 天)
显示 更早的评论
Could anyone say to me which is the problem here? Thanks in advance.
function F = prova(x)
k=1.38*10^(-23);
Tc=298.15;
q=1.6*10^(-19);
VT=k*Tc/q;
Isc=5.96;
Voc=62.18;
Imp=5.65;
Vmp=50.61;
Rs=0;
F(1)= x(1)-Isc-x(2)*(exp((Isc*Rs)/(x(3)*VT))-1);
F(2)= x(1)-Imp-x(2)*(exp((Vmp+Imp*Rs)/(x(3)*VT))-1);
F(3)= x(1)-x(2)*(exp((Voc)/(x(3)*VT))-1);
F=[F(1),F(2),F(3)];
x0=[6 0.5 1.2];
x=fsolve(@prova,x0);
end
0 个评论
采纳的回答
Star Strider
2020-2-6
One problem is that you are calling fsolve from within the ‘prova’ function.
Try this:
function F = prova(x)
k=1.38E-23;
Tc=298.15;
q=1.6E-19;
VT=k*Tc/q;
Isc=5.96;
Voc=62.18;
Imp=5.65;
Vmp=50.61;
Rs=0;
F(1)= x(1)-Isc-x(2)*(exp((Isc*Rs)/(x(3)*VT))-1);
F(2)= x(1)-Imp-x(2)*(exp((Vmp+Imp*Rs)/(x(3)*VT))-1);
F(3)= x(1)-x(2)*(exp((Voc)/(x(3)*VT))-1);
F=[F(1),F(2),F(3)];
end
x0=[6 0.5 1.2];
x=fsolve(@prova,x0);
However solving that problem throws::
Error using trustnleqn (line 28)
Objective function is returning undefined values at initial point. FSOLVE cannot continue.
Running this:
Q = prova(x0)
produces:
Q =
0.04 -Inf -Inf
This is most likely due to the vanishingly small values for ‘k’ and ‘q’. You have to solve that. (Scaling may be an option, such that al the constants are multiplied by 1E+10 or some such, then the ‘x’ values are appropriately re-scaled, if necessary.)
0 个评论
更多回答(1 个)
Alex Sha
2020-2-9
taking initial start-values as:
x0=[6 0.5 150];
will produce:
x1: 5.96
x2: 7.50486851347978E-7
x3: 152.194203428967
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!