https://pubs.acs.org/doi/abs/10.1021/j100540a008 - Official article link for implementing Gillespie algoirthm
이전 댓글 표시
https://pubs.acs.org/doi/abs/10.1021/j100540a008 - Official article link for implementing Gillespie algorithm
답변 (1개)
Geoff Hayes
2019년 2월 12일
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!