I have here an ODE to solve that has a test parameter a. I would like a to be a function of temperature T (in this code it is solved as X(2) since it varies with time).
I would like to base it off experimental values of a and T.
Hence, I am thinking of doing it along the lines of interp1.
Here is my test dummy ODE.
function xprime = RabbitTemp(t,X)
% Model of Rabbit Population
% where,
% Xo = Initial Population of Rabbits
% X(1) = Population density of Rabbit
% X(2) = Temperature T (that varies with time)
% a = test parameter
% Interpolate here
Texptdata = [1 2 3 4];
aexptdata =[10 14 19 30];
a= interp1(Texptdata,aexptdata,X(2),'spline');
% ODE
dx = [0 0];
dx(1) = (X(1))*(1 - X(1)*a - 3*(X(2))));
dx(2) = sin(t);
xprime = [dx(1) dx(2)]';
end
I've tried running the code with my solver and it does compile fine. However I am just wondering if the ODE solver is calling the correct interpolated a corresponding to the correct corresponding value of X(2). I cannot seem to figure out how to verify this.
Can anyone help me verify this or point me to how I can go about doing it? Much appreciated!