Why this ode45 solver gives NAN as output for f ?

조회 수: 2 (최근 30일)
Augustus
Augustus 2022년 4월 7일
댓글: Walter Roberson 2022년 4월 7일
I would like to solve df/dl = function (f), why it gives me NAN values as output ?
How should I fix that?
I have uploaded my files.
I really appreciate your help.
  댓글 수: 1
Star Strider
Star Strider 2022년 4월 7일
I cannot follow that code.
There are several examples of how to fit systems of differential equations to data in this search.

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

답변 (1개)

Walter Roberson
Walter Roberson 2022년 4월 7일
nT = sum(f(1):f(5));
That code means that the first value of the f vector should be looked up, and the 5th value of the f vector should be looked up, and that you should create a vector of values starting from the first one and incrementing by 1 and ending no later than the 5th value. So it is
sum(0.0104019018290415 : 1 : 0.0101171959808271)
but the last value f(5) is greater than the first value f(1), so you are asking to sum the empty vector, and the sum of the empty vector is 0.
Perhaps you wanted the code
nT = sum(f(1:5));
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 4월 7일
It is recommended that you do not readtable() inside the function. Read the table outside the function and pass it into the function, the way you pass f0 into the function.

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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by