how to interpolate the data over uniform time grid

조회 수: 7 (최근 30일)
PetronasAMG
PetronasAMG 2021년 9월 26일
댓글: Mathieu NOE 2021년 9월 27일
Since numerical solution obtained from ode45 is a non uniform in time, I need to obtain the frequency power spectrim of the solution, but first, i need to interpolate the date over unifrom time grid. How would i able to do so? I am completely stuck after inputting vlause from ODE45! Please explain the steps!
function dxdt = frs(t,x)
dxdt = zeros(3,1);
dx1dt = -((4/5)*x(2)+x(1));
dx2dt = x(3) + ((4/9)*x(2));
dx3dt = (1/8)+((x(1)-2.5)*x(2));
end
tspan = [0:10:100];
xi = [1.0;4.0;2.0];
[t,x]= ode45(@frs,tspan,xi);
from here I do not know how to process with the question please help!
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 9월 26일
Since numerical solution obtained from ode45 is a non uniform in time
That is only the case if you pass in a two-element tspan. When you pass in a tspan that is uniform in time, the way you do, then the output from ode45 will only be at those times, and so the output would be uniform in time.
Mathieu NOE
Mathieu NOE 2021년 9월 27일
you can also interpolate the output data of your ode solution over a new time vector (linear)
use interp1
maybe this will be faster than forcing ode to work on fixed , refined time vector

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

답변 (0개)

카테고리

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

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by