Kelsey - there are a couple of coding mistakes with the above. Before the code can execute, there is an error
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for
mismatched delimiters.
with the line
p(ip+1) = G*(pmax - p(t(ip))*p(t(ip))*dt+p(t(ip))
becaue there is a missing closing bracket. The above line should be
p(ip+1) = G*(pmax - p(t(ip))*p(t(ip))*dt+p(t(ip)));
Next, there is the error
Array indices must be positive integers or logical values.
with the line
As the error message indicates, positive integers or logical values must be used as indices. 0 is not a positive integer, so you if you want to find the delta, then just do
Similarly, you must change
p(0) = 800
p(1) = G*(pmax - p(0))*p(0)*dt+p(0)
for ip = 1:Nx
to
p(1) = 800
p(2) = G*(pmax - p(1))*p(1)*dt+p(1)
for ip = 2:Nx
The final problem will be with
p(ip+1) = G*(pmax - p(t(ip))*p(t(ip))*dt+p(t(ip)));
and the error
Array indices must be positive integers or logical values.
because of p(t(ip)) where you are using the vaues of t - which are not integers - as indices into p. What is this code trying to do here?
0 Comments
Sign in to comment.