I am using fsolve and receiving errors

3 views (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 24 Nov 2017
You did not happen to show you call to fsolve, with your initial conditions.
Stephen23
Stephen23 on 24 Nov 2017
Edited: Stephen23 on 24 Nov 2017
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.

Sign in to comment.

Answers (2)

Torsten
Torsten on 24 Nov 2017
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 Comments
Charalampos Ioannou
Charalampos Ioannou on 24 Nov 2017
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.

Sign in to comment.


Are Mjaavatten
Are Mjaavatten on 24 Nov 2017
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 Comments
Are Mjaavatten
Are Mjaavatten on 24 Nov 2017
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 on 24 Nov 2017
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 :)

Sign in to comment.

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!