Solving an equation with a summation

I am trying to solve the following equation for all other variables are known and k is the current loop value.
I am currently trying to use fsolve but it reachings its stoping critiera as soon as it begins.
fun = @(Lambda) cumsum(Pk - abs((ak./(Lambda + Tk))-((Ik+Pn)/(abs(hkk).^2))))
Lambda = fsolve(fun,0)
The output is shown below.
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead.
Equation solved at initial point.
fsolve completed because the vector of function values at the initial
point is near zero as measured by the value of the function tolerance,
and the problem appears regular as measured by the gradient.
<stopping criteria details>
Lambda = 0

8 comentarios

Choose an initial estimate for ‘Lambda’ that is something other than the trivial solution.
Even:
Lambda = fsolve(fun,1)
is likely to be an improvement, although experiment with different initial estimates to see what works best.
Whatever value I set the inital to is the asnwer it returns.
Lambda = fsolve(fun,1e-25)
% stopping criteria details
Lambda = 1.0000e-25
Every value less than eps (which on my machine is 2.220446049250313e-16), is essentially 0 in operations involving addition or subtraction.
I was thinking of something like:
Lambda = fsolve(fun,1)
or:
Lambda = fsolve(fun,42)
or something sufficiently distant from 0 as to be easily distinguishable from it in the computation.
Adam
Adam el 9 de Abr. de 2021
I have tried values ranging from 0 to 1000 and still get the same behaviour.
Star Strider
Star Strider el 9 de Abr. de 2021
The rest of your code is invisible, so I’m left to guess as to what the other variables are. My guess is that they are vectors, and that the code sums them and then attempts to estimate ‘Lambda’.
If they are, this is essentially curve-fitting, and fsolve may not be the correct optimisation function.
The intial posted code was modified to this, all values besides 'ak' and 'Pn' are vectors.
fun =@(lambda) Pk(n) - cumsum(abs((ak./(lambda + sum(Tk)))-((sum(Ik)+Pn)./sum(abs(hkk).^2))));
Lambda = fsolve(fun,1)
Would you have a sugestion for function I should use instead ?
Star Strider
Star Strider el 9 de Abr. de 2021
I have no idea.
I have to take your word that the rest of the code actually exists, however I continue to believe that this is curve-fitting, and that an appropriate curve-fitting function would be preferable to fsolve for this task.
Adam
Adam el 9 de Abr. de 2021
The code is based on the algrothim in the image, I have added the code as well.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Versión

R2020a

Preguntada:

el 9 de Abr. de 2021

Comentada:

el 9 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by