Initial conditions has two meanings:
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,...
hyperbolic solver, you must also
ut0, which is the value of the derivative
of u with respect to time at the initial time.
the same form as
For nonlinear elliptic problems, the initial condition
a guess or approximation of the solution u at the
initial iteration of the
solver. You pass
u0 in the
u = pdenonlin(b,p,e,t,c,a,f,'U0',u0)
If you do not specify initial conditions,
the zero function for the initial iteration.
u0 as a column vector of values at the
p in the usual
See Mesh Data. You can also pass
a scalar, which means the initial condition is a constant value.
Tip For reliability, the initial conditions and boundary conditions should be consistent.
The size of the column vector
on the number of equations, N, and on the number
of points in the mesh,
For scalar u, specify a column vector of
Np. The value of
k corresponds to the point
For a system of N equations, specify a column
vector of N*
Np elements contain
the values of component 1, where the value of element
p(k). The next
contain the values of component 2, etc. It can be convenient to first
represent the initial conditions
u0 as an
where the first column contains entries for component 1, the second
column contains entries for component 2, etc. The final representation
of the initial conditions is
For example, suppose you have a function
calculates the value of the initial condition
a row vector of length N. Suppose that
the usual mesh point data (see Mesh Data).
Compute the initial conditions for all mesh points
% 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
u0 as the initial condition.
with scalar problems, you can also specify text expressions for the
initial conditions. The initial conditions are functions of x and y alone,
and, for 3-D problems, z.
For example, if you have an initial condition
then you can use this expression for the initial condition.