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!