I am using fsolve and receiving errors

조회 수: 17 (최근 30일)
Charalampos Ioannou
Charalampos Ioannou 2017년 11월 24일
댓글: Charalampos Ioannou 2017년 11월 24일
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일
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에서 Data Type Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by