Group Abstract Group Abstract

Message Boards Message Boards

Use NDSolve to calculate a particular x-value, given y-value?

Posted 4 years ago

Hello,

I am trying to use the interpolating function generated by NDSolve to calculate the time at which the function reaches a value of 1. I tried the following code:

q = 3/100
c = 1/2
b = d = 1
k = G = 20000
g = 1
slv = NDSolve[{x'[t] == x[t]*b*h[t]/G - x[t]*d*x[t]/k, 
   y'[t] == 
    y[t]*b*(1 - c*g)*h[t]/G + y[t]*b*(1 - c*g)*g*(1 - h[t]/G) - 
     y[t]*d*(x[t])/k, h'[t] == -q*h[t], x[0] == k, y[0] == 1, 
   h[0] == G}, {x, y, h}, {t, 0, 1000}]

FindRoot[x[t] /. slv == 1, {t, 0}]

But receive the following error:

FindRoot::nlnum: The function value {-1.+x[0.]} is not a list of numbers with dimensions {1} at {t} = {0.}.

Any help would be greatly appreciated!

Thank you,

Alex

Attachments:
POSTED BY: Alex L
2 Replies
Posted 4 years ago
POSTED BY: Bill Nelson
Posted 4 years ago

Thank you!! I see what I was doing wrong now.

POSTED BY: Alex L
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard