I need to solve an advection-diffusion equation of the form:
$\frac{∂u}{∂t}=\frac{1}{x}\frac{∂u}{∂x}+\frac{∂^2 u}{∂x^2 } $
with MATLAB. Could you guide me, please? Is the Crank-Nicolson method proper method for this equation?
You will have a problem if $x=0$ is part of your domain because in that case your advection velocity $u=1/x$ becomes singular. In particular, there will be cells close to $x=0$ where the cell Peclet number is very large, and consequently you will be in the advection-dominated regime. You will need to stabilize your discretization.
Well, you can use Crank-Nicolson here but then you'll have to construct and solve a linear system for each time-step. That's easy to do but it would be much easier to use an ODE integrator that is available in MATLAB. Due to the diffusion operator in the RHS the implicit integrator ode23tb seems to be a good choice here but experimenting with different integrators will be helpful. What is needed is (1) discretize your PDE by finite-difference on a grid in x, (2) at each grid point $x_i$ you'll have an ODE for time-evolution of $u_i(t)$, (3) write a function, say $myrhs()$, representing the whole set of these ODEs, one for each grid point, (4) look up a usage example for the chosen ODE integrator in MATLAB manuals and call it with $myrhs$ as an argument (other arguments will be the time step, time limits etc). That's it.