Asked by Jeremy Pearson
on 9 Jan 2013

I have created a square in the PDEtoolbox GUI throughout which the toolbox has solved for diffusion of particles towards the center of the square and for particle flux at any x and y.

To create a function that solves for flux at any x and y in the command window, I have exported the mesh and solution from the PDEtoolbox to the command window, specifically p and u parameters respectively, and used the TriScatteredInterp to create this function F(x,y) in the command window:

F = TriScatteredInterp(p (1,:)', p (2,:)', u);

When I save my work in the PDEtoolbox GUI, it shows up as a “function” in the “current folder” section (which makes me think this function may be used in the command window directly in other manipulations).

I would now like to repeat this process with multiple surface boundary conditions (i.e. different initial fluxes defined in the PDEtoolbox GUI at the surface of the square) and solve for the respective flux profiles (F(x,y)).

Rather than setting this up over and over again in the PDEtoolbox GUI and exporting parameters over and over, is there a way that I can

1. Modify the coding in the “PDEtoolbox function” I have created to contain a variable for the surface flux boundary condition rather than a specific value,

2. Define a value or array of values for this variable in the command window,

3. Call the “PDEtoolbox function” in the command window and pull the mesh values and solution from it for input into the TriScatteredInterp function to create a solution or solutions for F(x,y)? Or perhaps a function F(x,y,a) where “a” is the variable representing the surface flux on the square? (Therefore the need to create a whole new picture in the PDE toolbox GUI and export parameters for each new condition is avoided)

Thanks for any tips!

Jeremy

*No products are associated with this question.*

Answer by Bill Greene
on 6 Feb 2013

Accepted answer

Hi,

The "function" file created by pdetool when you select the "Save As" option is really for the use of pdetool, only. It is generally not recommended that you manually edit that file and it isn't useful for automating a pde solution from the command line.

An alternate approach is this:

- Export any non-changing model matrices from pdetool to the MATLAB command line (e.g. the geometry matrices)
- Use the PDE Toolbox command-line functions to calculate the solution from your changed input (e.g. assempde).

You mentioned that you want to change your boundary conditions. The most straightforward way to do this is by writing a "boundary file" which is just a function that you write to define boundary conditions.

There are several examples of using PDE Toolbox from the command line here: http://www.mathworks.com/help/pde/examples/index.html

Bill

Jeremy Pearson
on 6 Feb 2013

Hello Bill,

Thanks for your kind response. This helps me know that the "function" shouldn't be used for automating a solution in the command line to save time. You also gave me another logical approach which appears that it could save time and do what I was looking to do. I'll have to give this a shot and possibly come back with some questions later if I have any,

Thanks Bill!

Jeremy

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments