3

I've an equation like this to solve with the crank-nicolson method

$$U_t -\frac{y}{2} U_x + \frac{x}{2}U_y = 0,$$

where $x$ and $y$ are: [-2,5:2,5] and the time $T$ is from $0$ to $2\pi$. Is there anyone who can help me? I have to solve it in a matlab code. thanks everyone. I'm sorry for my english.

Ysmael
  • 31
  • 4

1 Answers1

3

Here is a tutorial on how to solve this equation in 1D with example code. The code is Python (which is similar to MATLAB so you should be able to translate). To extend this to 2D you just follow the same procedure for the other dimension and extend the matrix equation.

How to discretize the advection equation using the Crank-Nicolson method?

boyfarrell
  • 5,409
  • 3
  • 35
  • 67