https://pubs.acs.org/doi/abs/10.1021/j100540a008 - Official article link for implementing Gillespie algoirthm
Mostrar comentarios más antiguos
https://pubs.acs.org/doi/abs/10.1021/j100540a008 - Official article link for implementing Gillespie algorithm
Respuestas (1)
Geoff Hayes
el 12 de Feb. de 2019
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?
Categorías
Más información sobre Aerospace Blockset en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!