How do I create uneven initial conditions in the Partial Differential Equation Toolbox?

1 view (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
According to the documentation of Partial Differential Equation Toolbox, the initial value can be a constant or a column vector of values on the nodes of the current mesh. The following example will demonstrate how you can have various initial conditions.
1) Draw a geometry in the PDE GUI.
2) Set the PDE coefficients in the PDE Mode.
3) Create the mesh in the Mesh Mode.
4) Export the Mesh (p, e, t) from the Mesh Mode
To determine the number of nodes in the Mesh, type the following at the MATLAB command prompt:
numofnodes=size(p,2)
Once you determine the number of nodes, create a function that will return the column vector of values on the nodes:
function y = myfunc(x,y)
y=zeros(101,1); %in my case I had 101 nodes
y(45:50)=10; % different initial conditions at this nodes
5) In the PDE GUI, use the function 'myfunc' rather than a constant value. ( (to)=myfunc ')
6) In the Plot Selection, select the 'Time for plot' as 0 and click the Plot button

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!