## Documentation Center |

*Initial conditions* has two meanings:

For the

`parabolic`and`hyperbolic`solvers, the initial condition`u0`is the solution*u*at the initial time. You must specify the initial condition for these solvers. Pass the initial condition in the first argument or arguments.u = parabolic(u0,... or u = hyperbolic(u0,ut0,...

For the

`hyperbolic`solver, you must also specify`ut0`, which is the value of the derivative of*u*with respect to time at the initial time.`ut0`has the same form as`u0`.For nonlinear elliptic problems, the initial condition

`u0`is a guess or approximation of the solution*u*at the initial iteration of the`pdenonlin`nonlinear solver. You pass`u0`in the`'U0'`name-value pair.`u = pdenonlin(b,p,e,t,c,a,f,'U0',u0)`

If you do not specify initial conditions,

`pdenonlin`uses the zero function for the initial iteration.

Pass `u0` as a column vector of values at the
points `p` in the usual `p`, `t`, `e` mesh.
See Mesh Data. You can also pass
a scalar, which means the initial condition is a constant value.

The size of the column vector `u0` depends
on the number of equations, *N*, and on the number
of points in the mesh, `N _{p}`.

For scalar *u*, specify a column vector of
length `N _{p}`. The value of
element

For a system of *N* equations, specify a column
vector of *N**`N _{p}` elements.
The first

For example, suppose you have a function `myfun(x,y)` that
calculates the value of the initial condition `u0(x,y)` as
a row vector of length *N*. Suppose that `p` is
the usual mesh point data (see Mesh Data).
Compute the initial conditions for all mesh points `p`.

% Assume N and p exist; N = 1 for a scalar problem np = size(p,2); % Number of mesh points u0 = zeros(np,N); % Allocate initial matrix for k = 1:np x = p(1,k); y = p(2,k); u0(k,:) = myfun(x,y); % Fill in row k end u0 = u0(:); % Convert to column form

Specify `u0` as the initial condition.

For the `parabolic` and `hyperbolic` solvers
with scalar problems, you can also specify text expressions for the
initial conditions. The initial conditions are functions of *x* and *y* alone.

For example, if you have an initial condition

then you can use this expression for the initial condition.

`'x.*y.*cos(x)./(1+x.^2+y.^2)'`

`hyperbolic` | `parabolic` | `pdenonlin`

Was this topic helpful?