A PDE model stores initial conditions in its
InitialConditions property. Suppose
model is the name of your model. Obtain the initial conditions:
inits = model.InitialConditions;
To see the active initial conditions assignment for a region, call the
findInitialConditions function. For example, create a model and view the geometry.
model = createpde(); geometryFromEdges(model,@lshapeg); pdegplot(model,'FaceLabels','on') ylim([-1.1,1.1]) axis equal
Specify constant initial conditions over all the regions in the model.
Specify a different initial condition on each subregion.
View the initial condition assignment for region 2.
ics = model.InitialConditions; findInitialConditions(ics,'Face',2)
ans = GeometricInitialConditions with properties: RegionType: 'face' RegionID: 2 InitialValue: 3 InitialDerivative: 
This shows the "last assignment wins" characteristic.
View the initial conditions assignment for region 1.
ans = GeometricInitialConditions with properties: RegionType: 'face' RegionID: [1 2 3] InitialValue: 2 InitialDerivative: 
The active initial conditions assignment for region 1 includes all three regions, though this assignment is no longer active for regions 2 and 3.
To delete all the initial conditions in your PDE model, use
model is the name of your model. Remove
all initial conditions from
To delete specific initial conditions assignments, delete them
icv = model.InitialConditions.InitialConditionAssignments; delete(icv(2))
You do not need to delete initial conditions; you can override
them by calling
setInitialConditions again. However,
deleting unused assignments can make your model smaller.
To change an initial conditions assignment, you need the initial conditions handle. To get the initial condition handle:
Retain the handle when using
ics1 = setInitialConditions(model,2);
Obtain the handle using
ics = model.InitialConditions; ics1 = findInitialConditions(ics,'Face',2);
You can change any property of the initial conditions handle. For example,
ics1.RegionID = [1,3]; ics1.InitialValue = 2; ics1.InitialDerivative = @ut0fun;
Editing an existing assignment in this way does not change its
priority. For example, if the active initial conditions in region
ics1, then editing
3 does not make
active initial condition in region