@Amal Matrafi, could you please provide the ode45 code so that we can check? We are not experts in the SI model. Is 'SI' an abbreviation for something?
By the way, could you solve this ODE and plot the derivative of ?
There are other, more direct (and probably more accurate) ways of calculating it from the original differential equation function. That requires a loop.
You can use deval() to obtain the first derivative. Alternatively, as suggested by @Star Strider, you can also use the gradient() approach to obtain the first derivative.
beta = [0.1, 0.2, 0.25];
N = 1000;
tend = 150;
I0 = 10;
tspan = [0,tend];
S0 = N - I0;
y0 = [S0; I0];
opts = odeset('RelTol', 1e-2, 'AbsTol', 1e-4);
for j = 1:numel(beta)
sol = ode45(@(t, y) SIRfunc(t, y, beta(j), N), tspan, y0, opts);
Before learning to use deval(), I utilized the right-hand side of the state equation by directly substituting the solution from ode45(). This is pure math stuff!