I am using fsolve and receiving errors

1 次查看(过去 30 天)
I have the following function which i am defining some of the parameters as follows:
function F = solar5d(x)
q = 1.60217662*10^-19;
k = 1.38064852*10^-23;
T = 298.15; % Temperature in degrees 25. This one is in Kelvin.
Ns = 72;
Np = 1;
Voc = 44.6;
Vm = 35.43;
Isc = 5.43;
Im = 4.95;
n = 1.086;
These are my unknown parameters i am looking for:
Iph = x(1);
Io = x(2);
Rs = x(3);
Rp = x(4);
Vt = x(5);
The following are the six questions i have to solve the system:
F(1) = Vt - n*k*T/q;
F(2) = Np*Iph - Np*Io*(exp(Voc/Ns*Vt)-1) - (Np*Voc)/(Ns*Rp);
F(3) = Np*Iph - Np*Io*(exp((Isc*Rs)/(Np*Vt)) - 1) - (Isc*Rs)/Rp - Isc;
F(4) = Np*Iph - Np*Io*(exp(((Vm/Ns)+(Im*Rs)/Np)/Vt) - 1) - Np*((((Vm/Ns)+((Im*Rs)/Np))/Rp)) - Im;
F(5) = (((Np/Ns*Vt)*Io*(exp((Vm + ((Im*Ns*Rs)/Np))/Ns*Vt)) + (1/(Ns*Rp)/Np))/(1 + (Rs*Vt)*Io*(exp((Vm + ((Im*Ns*Rs)/Np))/Ns*Vt)) + (Rs/Rp))) - (Im/Vm);
F(6) = (((-Np/Ns*Vt)*Io*(exp(Voc/Ns*Vt)) - (1/Ns*Rp/Np)) / (1 + (Rs/Vt)*Io*(exp(Voc/Ns*Vt)) + (Rs/Rp))) + 1/Rs;
end
But i am receiving the following error:
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle
non-square systems; using Levenberg-Marquardt algorithm instead.
> In fsolve (line 298)
Error using levenbergMarquardt (line 16)
Objective function is returning undefined values at initial point.
fsolve cannot continue.
Error in fsolve (line 397)
levenbergMarquardt(funfcn,x,verbosity,options,defaultopt,f,JAC,caller,
...
Please could you help me to solve my problem??
Thanks in advance.
Regards,
Charalampos
  2 个评论
Walter Roberson
Walter Roberson 2017-11-24
You did not happen to show you call to fsolve, with your initial conditions.
Stephen23
Stephen23 2017-11-24
编辑:Stephen23 2017-11-24
Note that
q = 1.60217662*10^-19;
requires three numbers and two expensive operations to generate the output value, whereas
q = 1.60217662e-19;
is efficiently defined as that value, without any operations.

请先登录,再进行评论。

回答(2 个)

Torsten
Torsten 2017-11-24
Add
disp(F)
at the end of solar5d.
I suspect that the array F contains Inf, NaN or something similar.
Take care that your initial values for the variables don't produce division by zero or undefined expressions.
Best wishes
Torsten.
  7 个评论
Charalampos Ioannou
Charalampos Ioannou 2017-11-24
The pictures i post above are the equations i am using in the algorithm i post. The first 3 equations i rearranged them to be equal to zero the 4 one the same and then i choose question (15) to be as my fifth equation and i rearrange it to be equal to zero again.

请先登录,再进行评论。


Are Mjaavatten
Are Mjaavatten 2017-11-24
It seems that you try to solve an overdetermined system. You have six equations in five unknowns. You should re-examine your problem to see if one of your equations is superfluous.
Also, it is good practice (although not strictly necessary) to pre-allocate memory to F: Insert the command
F = zeros(6,1) % Or zeros(5,1)?
before you define the components of F.
  9 个评论
Are Mjaavatten
Are Mjaavatten 2017-11-24
Did you check that fsolve converged at all? If so, if you plug the resulting x into solar5d the result should be a set of very small numbers. Solving a set of nonlinear equations is not always easy. In the general case, a solution may not even exist.
If you have some knowledge of what the solution should be, try with a starting vector close to this estimate. It may also be a good idea to double-check that your equations and parameters are all correct
Charalampos Ioannou
Charalampos Ioannou 2017-11-24
Hello Are,
I have the solutions from a different source so i will try to get that solutions include them in the equations and see if i will get zero.
If i am getting zero that means the equations are correct i will try to doing it now and see. Thanks for your help :)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by