How to set the coefficient of PDE equation as a user-defined matlab function?

2 views (last 30 days)
Hi,
My problem is Possion's equation. I use assempde function to solve my problem in command lines. The coefficient c is denpended on coordinate x,y. But, c cannot be writed as a simple expression with x,y. So I write a function to interpolate the value.
I looked up in the help documnent of "assempde". It says that "The name of a user-defined MATLAB function that accepts the arguments (p,t,u,t0). "
Does it mean I cannot use the coordinate value x,y?
What should the function return? A matrix or a vector??Could you give me more details?
Thanks!
Qingyuan

Accepted Answer

Bill Greene
Bill Greene on 3 Jan 2012
Qingyuan,
As you've observed, supplying a MATLAB function for the c coefficients is somewhat different than if you just directly type a MATLAB expression for the c coefficients in the dialog box.
But, yes, c can be a function of x and y. You have the correct set of input arguments for the required function-- (p,t,u,t0). The first argument p contains the x and y locations of all nodes in the mesh and t contains the 3 nodal indices for all triangle elements in the mesh. From these two arguments you can compute the x and y locations for the centroid of each triangle element.
The return parameter for this function is a matrix of c coefficients at each element centroid. The number of columns in the returned c matrix is equal the number of elements in the mesh. The number of rows depends on the characteristics of the c matrix. For example, for the scalar Poisson equation for an isotropic material, the number of rows is one. The different forms of the c matrix for a single PDE as well as a system of PDEs are described on pages 5-21 and 5-22 of the PDE Toolbox User's Guide.
Bill

More Answers (2)

Ruslan
Ruslan on 8 Dec 2011
"The expression is evaluated in a context where the variables x, y, sd, u, ux, uy, and t are row vectors representing values at the triangle centers of mass (t is a scalar). The row vectors contain x- and y-coordinates, subdomain label, solution, x and y derivatives of the solution, and time. u, ux, and uy can only be used if u0 has been passed to assempde. The same applies to the scalar t, which is passed to assempde as time."
What's your version of MATLAB? You can use 'x' and 'y' in your analytical expression in coefficients or as a "row vector of values at the triangle centers of mass".

zhao qingyuan
zhao qingyuan on 3 Jan 2012
I have resolved this problem. Thank you for all your help!

Community Treasure Hunt

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

Start Hunting!