- #1

skyflashings

- 15

- 0

I have a matrix which represents a coordinate system (x, y) with varying degrees of height at each point. Using Matlab, I made a matrix with a gradient (u and v components) across the system.

Now, I want to place a particle at some point in the system and watch it's path be 'pushed' around by the gradients over time. You can imagine this like the current in an ocean pushing a boat around I guess.

I have applied Euler's method to this, and it was successful. Of course, the problem is Eulers is not that accurate, so I want to try RK4 to get a better path approximation. This is where I get lost. For Euler's, I used pathX(i) = pathX(i-1) + u(x, y) * dt and pathY(i) = pathY(i-1) + v(x, y) * dt. Since u and v are the partials (gradients) of the original height data, it seems to work fine.

For RK4, I need more than just the gradient I think. But I don't really know how to approach it. I am finding it difficult because I don't really know of a 'function' per se to plug values into. What does f(xi + (1/2)*h, yi + (1/2)*k1*h) mean in my context? Is it referring to solving the function using a different kind of stepped gradient or something else?

I would appreciate any help. If I am confusing or didn't explain the situation well, please ask! Thanks.