How do I specify the coefficients of a PDE which depends on the "x" and "y" coordinates using the Partial Differential Equation Toolbox?

1 view (last 30 days)
For the case when using the Partial Differential Equation Toolbox in "eigenmode" with the PDE coefficients "c=1", "a=0", and "d=rho3(x)" on a circular domain with center (0,0) and radius 1 and Dirichlet condition "u=0":
The solver appears to treat the function "rho3(x)" as a constant function "y=1" rather than the step function taking values "y=2" on a part of the region.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The reason is because of the function RHO3. The input "x" is a vector of "x"-coordinates. Thus, in the code, "y" is also assigned to 1 only.
The output "y" ( the values of "d") should be a vector, as well.
Try the following code:
function y=rho3(x)
% radial density function 3
y =ones(size(x));
idx = find((x < 0.5) & (x >= 0.0));
y(idx) = 2

More Answers (0)

Community Treasure Hunt

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

Start Hunting!