Documentation |
Write a text expression using these conventions:
'x' — x-coordinate
'y' — y-coordinate
'u' — Solution of equation
'ux' — Derivative of u in the x-direction
'uy' — Derivative of u in the y-direction
't' — Time (parabolic and hyperbolic equations)
'sd' — Subdomain number
For example, you could use this string to represent a coefficient:
'(x+y)./(x.^2 + y.^2 + 1) + 3 + sin(t)./(1+u.^4)'
You can write MATLAB^{®} functions for coefficients as well as plain text expressions. For example, suppose your coefficient f is given by the file fcoeff.m:
function f = fcoeff(x,y,t,sd) f = (x.*y)./(1+x.^2+y.^2); % f on subdomain 1 f = f + log(1+t); % include time r = (sd == 2); % subdomain 2 f2 = cos(x+y); % coefficient on subdomain 2 f(r) = f2(r); % f on subdomain 2
Represent this function in the parabolic solver, for example:
u1 = parabolic(u0,tlist,b,p,e,t,c,a,'fcoeff(x,y,t,sd)',d)
There is a simple way to write a text expression for multiple subdomains without using 'sd' or a function. Separate the formulas for the different subdomains with the '!' character. Generally use the same number of expressions as subdomains. However, if an expression does not depend on the subdomain number, you can give just one expression.
For example, an expression for an input (a, c, f, or d) with three subdomains:
'2+tanh(x.*y)!cosh(x)./(1+x.^2+y.^2)!x.^2+y.^2'
The coefficient c is a 2-by-2 matrix. You can give c in any of the following forms:
Scalar or single string — The software interprets c as a diagonal matrix:
$$\left(\begin{array}{cc}c& 0\\ 0& c\end{array}\right)$$
Two-element column vector or two-row text array — The software interprets c as a diagonal matrix:
$$\left(\begin{array}{cc}c(1)& 0\\ 0& c(2)\end{array}\right)$$
Three-element column vector or three-row text array — The software interprets c as a symmetric matrix:
$$\left(\begin{array}{cc}c(1)& c(2)\\ c(2)& c(3)\end{array}\right)$$
Four-element column vector or four-row text array — The software interprets c as a full matrix:
$$\left(\begin{array}{cc}c(1)& c(3)\\ c(2)& c(4)\end{array}\right)$$
For example, c as a symmetric matrix with cos(xy) on the off-diagonal terms:
c = char('x.^2+y.^2',... 'cos(x.*y)',... 'u./(1+x.^2+y.^2)')
To include subdomains separated by '!', include the '!' in each row. For example,
c = char('1+x.^2+y.^2!x.^2+y.^2',... 'cos(x.*y)!sin(x.*y)',... 'u./(1+x.^2+y.^2)!u.*(x.^2+y.^2)')
For elliptic problems, when you include 'u', 'ux', or 'uy', you must use the pdenonlin solver instead of assempde. In the PDE app, select Solve > Parameters > Use nonlinear solver.