# Dirichlet boundary condition

I am trying to solve ODEs in matlab using ode15s. Instead of specifying ODEs in the format

  M * dC/dt = f(C,t)  where C is a function of x and t.


I want to use

  M * dC/dt = J*C


Since the vector C is very large I am expecting considerable reduction in computation time. I am trying to figure out how to code the Dirichlet boundary condition C(x=0,t) = a. thanks

• You just need to edit the first and last equations of you matrix equation to make sure they always have a fixed value. – boyfarrell Feb 13 '15 at 9:14
• @AseemKashyap: Please do not add edits to your original post as answers. Edit your question instead. StackExchange enables you to write equations in LaTeX format, which will be rendered into graphics using MathJax. – Geoff Oxberry Feb 19 '15 at 5:16

Typically, you would impose the Dirichlet conditions as initial conditions. If $C_{i}$ corresponds to an initial condition for each index $i$ in some set, you would set each of these $C_{i}$s to a fixed value (the Dirichlet initial condition), and then make sure that $f_{i}$ is set to zero, and the $i$th row of $M$ is the $i$th row of the identity matrix.