https://pu​bs.acs.org​/doi/abs/1​0.1021/j10​0540a008 - Official article link for implementing Gillespie algoirthm

답변 (1개)

Kevin - you will need to review the following block of code
mu = sum(r(2)*a0 <= cumsum(a));
t = t + tau;
switch mu
case 1
X(mu) = X(mu) - 1;
end
n = n + 1;
Xplot(mu,n+1) = X(mu);
When I run your script, the mu variable is set to 4 (on the first iteration of the while loop). Since this case isn't handled in the switch statement (not sure why you only handle the case where mu is one, is this intentional? do you even want a switch here?) then there isn't any change to X which is a scalar (assigned the value of one previously). And so the line
Xplot(mu,n+1) = X(mu);
will generate the above error since you are trying to access an element using an index (4) that is invalid for your array (of length 1). What is it that you really want to be doing at these lines? How should mu and X work together?

카테고리

도움말 센터File Exchange에서 Aerospace Blockset에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2019년 2월 11일

편집:

2019년 2월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by