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

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 2021년 4월 9일
I have tried values ranging from 0 to 1000 and still get the same behaviour.
Star Strider
Star Strider 2021년 4월 9일
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 2021년 4월 9일
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 2021년 4월 9일
The code is based on the algrothim in the image, I have added the code as well.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2021년 4월 9일

댓글:

2021년 4월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by