MATLAB: Attempting to solve differential equation model of windkessel two element using ode45, getting errors

ode 45

Hello, I am trying to use ode45 to solve numerically for pressure for the equation below: dP/dt = Q(t)/C -P(t)/R*C where R and C are known constants and I am given Q(t) as a matrix of size (206X1) stored in variable named flow. I'm suppose to use Q(t) to solve numerically for pressure and I tried using ode45 but I get the error "Error using odearguments (line 92) @(T,Y)QT/C-Y/R*C returns a vector of length 206, but the length of initial conditions vector is 1. The vector returned by @(T,Y)QT/C-Y/R*C and the initial conditions vector must have the same number of elements." this is my code: tspan= 0:1:206 Qt = flow(:,:) y0 = 0; [t,y] = ode45(@(t,y) Qt/C-y/R*C,tspan,y0) It seems my problem is with figuring out how to put Q(t) in the write syntax for ode45.
Thanks.

Best Answer

You are doing curve fitting (also known as parameter estimation). The code in Monod kinetics and curve fitting (link), although an enzyme kinetics problem, will demonstrate how to integrate a differential equation using ode45 and estimate the parameters of the system. You should easily be able to adapt it to your problem.
Related Question