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
Star Strider
2021년 4월 9일
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.
Adam
2021년 4월 9일
Star Strider
2021년 4월 9일
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
2021년 4월 9일
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.
Adam
2021년 4월 9일
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
2021년 4월 9일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!