Alternatively, if I try this:
n = 1000;
result = zeros(n,1);
for k=1:n
tspan=[1 7];A0=rand(n);P0=rand(n);g=rand(n);p=rand(n);B=rand(n);
[t,x] = ode45(@(t,x) [-g*x(1) + p*x(1); -x(1)*x(2)+ B*x(2)], tspan, [A0 P0])
result(k) = x(n);
end
I get the following error:
Error using odearguments (line 93)
@(T,X)[-G*X(1)+P*X(1);-X(1)*X(2)+B*X(2)] must return a column vector.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);