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).(adsbygoogle = window.adsbygoogle || []).push({});

Instead of picking 1 random variable for "rand" for the entire x domain, I want "rand" to be different for each step i.e. a different "rand" for x=1, x=2, x=3, etc.Code (Text):

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}]

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# How do you update variables in NDSolve for each step?

**Physics Forums | Science Articles, Homework Help, Discussion**