Matlab functions of variables

66 Views Asked by At

So I am writing a function to compute the following equations for an SIR model:

enter image description here

So here's my code:

function xdot = sir(t, params)
global h r q;

xdot = zeros(3,1);
SH = params(1);
IH = params(2);
RH = params(3);

xdot(1) = -h*SH + r*IH + gamma(h,t)*RH; % dSh
xdot(2) = h*SH - r*IH - q*IH; %dIh
xdot(3) = q*IH - gamma(h,t)*RH; %dRh

end

And then I would call this function like so:

global h r q;
h = 1;
r = 2;
q = 3;
params(1) = 1;
params(2) = 2;
params(3) = 3;
[t x] = ode45('sir',[0:0.01:30],params);

But I just don't understand how to write the function component inside of sir.m. What i mean is this part: $$\gamma(h,\tau)$$ that is part of the original equation. How exactly would I write this inside the function file?