Your boundary condition function includes the line
TT(i) is not defined within view of the function, so that is what is causing the error. To make that work you need to pass TT in as an extra parameter. But, still, the index i is undefined. So I would recommend just doing something like:
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
Tg = 25;
pl = ul-Tg;
ql = 0;
pr = 0;
qr = 1;
If you really want to pass in TT as a parameter, change the header of the boundary function to
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t,TT)
and then define the variable
bc = @(xl,ul,xr,ur,t) pdex1bc(xl,ul,xr,ur,t,TT);
This allows pdepe to pass in the 4 inputs it expects, and allows you to pass in the extra TT input from the workspace. You'll need to define the index i somewhere within pdex1bc as well. The call to pdepe then becomes
sol = pdepe(m,@pdex1pde,@pdex1ic,bc,x,t);
Also, although these don't cause errors some other possible issues are:
- The constant k appears in your flux term f = ..., but not in your original equation.
- Your source term should just be s = 0 from the original equation, but you have lines to define y, F, and s.
Best Answer