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!