| New Reply |
How do you update variables in NDSolve for each step? |
Share Thread | Thread Tools |
| May22-12, 12:19 AM | #1 |
|
|
How do you update variables in NDSolve for each step?
Im using NDSolve. I need to be able to update a variable inside NDSolve each time NDSolve takes a step. "rand" is the variable I want to update each step. I want it to be a different number each step. The below is an example that illustrates what I have currently happening ("rand" does not update for each step).
Code:
rand=RandomReal[]
Solution = y /. Flatten[ NDSolve[{y'[x] == .25 rand, y[0] == 1}, y, {x, -10, 10}]]
Plot[Evaluate[Solution[x]], {x, -10, 10}, PlotRange -> {-1.5, 1.5}]
|
| May22-12, 03:24 AM | #2 |
|
|
When you say each step, do you mean each step in x i.e step in the internal integration?
If so then the only way I can think of at the moment (not even sure if this is what you want) is to generate a table of random points, each associated with an x value and parse that as a function of x, i.e. y'[x] = 0.25 f(x) where f(x) maps to your interpolated random set. |
| May22-12, 12:32 PM | #3 |
|
|
yes, when i say step i mean each step in x inside of NDSolve.
I think i may have found an answer to this. Im posting it incase anyone else should ever find this and need help. The ?NumericQ prevents the expression simply getting replaced by RandomReal[]. rand[x_?NumericQ] := RandomReal[]; Solution = y /. Flatten[NDSolve[{y'[x] == .25 rand[x], y[0] == 1}, y, {x, -10, 10}, PrecisionGoal->0]] |
| May22-12, 04:33 PM | #4 |
|
|
How do you update variables in NDSolve for each step?
You could also probably wrap it in an Evaluate[].
|
| New Reply |
| Thread Tools | |
Similar Threads for: How do you update variables in NDSolve for each step?
|
||||
| Thread | Forum | Replies | ||
| I'm looking for a software program that solves physics problems step by step to learn | Math & Science Software | 2 | ||
| NDSolve Quirkiness - Updating the initial conditions after each step? | Differential Equations | 0 | ||
| Step-by-step guide to mastering calculus from little/no maths knowledge | Academic Guidance | 2 | ||
| Newb Success! Gfortran & G77 in Vista. Step by Step Tutorial. | Programming & Comp Sci | 7 | ||
| Complex Variables: Missing Step in Example | Calculus & Beyond Homework | 2 | ||