How to enter large functions in pdetool of MATLAB

101 Views Asked by At

I am working with pdetool of MATLAB for solving certain parabolic pde. As you know there are prescribed format in pdetool for example in the parabolic case we have $$du^{'}+{\rm div}(c*{\rm grad}(u))+a*u=f$$
where the values of $d,c,a,f$ should be specified.

My question is that can we enter $f$ or other parameters as a MATLAB function?

for example Dirac delta or anything else.

Thanks a lot for your kind attention.

1

There are 1 best solutions below

1
On BEST ANSWER

Suppose you define a function $f(x,y) = y^2\tan(x)$ via

function fcn = fcn(x,y)

fcn = tan(x).*y.^2;

end

then when you solve the PDE, define $x$ and $y$ as symbolic variables, and do the following:

syms x y

c = 1;

a = 'x.*y'; % for example

f = 'fcn(x,y)';

d = 1;

u = parabolic(u0,tlist,model,c,a,f,d);