# Problem with pdepe

• MATLAB
Homework Helper

## Summary:

I have an error with not enough input parameters

## Main Question or Discussion Point

Matlab:
function sol=temp_pde(t,R,X,source)

m=1; %Sets the geometry to cylindrical
global theta kappa h Q;
theta=X(1); kappa=X(2); h=X(3);
r=linspace(0,R,800);
Q=source;
sol=pdepe(m,pdefun,icfun,bcfun,r,t);
end

function [c,f,s] = pdefun(r,t,u,DuDx)
global theta kappa Q;
c = theta;
s = Q;
f = kappa*DuDx;

end

function u0 = icfun(r)
u0 = 0;
end

function [pl,ql,pr,qr] = bcfun(xl,ul,xr,ur,t)
global h kappa;
pl = 0;
ql = 1;
pr = h*ur;
qr = kappa;
end
I'm unsure why I'm getting problems with not enough input arguments. Any suggestions?

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
Homework Helper
So I changed that and I still get an error, it comes up with:

246 [c,f,s] = feval(pde,xi(1),t(1),U,Ux,varargin{:});
247 if any([size(c,1),size(f,1),size(s,1)]~=npde)
248 error(message('MATLAB:pdepe:UnexpectedOutputPDEFUN',sprintf('%d',npde)))

The value c is just a single number. This should be okay but I don't understand it,

jedishrfu
Mentor
You probably have to go back to the example and look at what args your functions accept vs what args the pdepe will pass to them.

Basically pdepe is acting as a kind of convenience wrapper function that is taking some hidden data and passing it to your functions in the form of arguments. Some of this hidden data may in fact be outputs of your other functions being fed back into your functions.

Because of that you need to check for each function:
- number of input args match what pdepe expects
- datatypes of input args match what pdepe expects
- number of output values match what pdepe expects
- datatypes of output values match what pdepe expects

Last edited:
Homework Helper
So I checked the link and I think I've got the same thing they have. It centres around the value of c I think, they have a constant, I have a constant but it still causes issues which seems to be a problem.

jedishrfu
Mentor
Can you try running their example? Sometimes that will give you something to compare against.

Homework Helper
I might have to give up with this and go back to my own code. One of the things which annoys me about matlab inbuilt functions in the arbitrary way of doing things. Often wring your own code is quicker and faster and trying to understand the idiosyncrasies of their function.

DrClaude
Mentor
@hunt_mat: I took your code, only modified the line
Matlab:
sol=pdepe(m,@pdefun,@icfun,@bcfun,r,t);
defined some dummy arguments for t, R, X, and source, and it works.

Homework Helper
I added the line: Q = @(z) interp1(t,source,z); and it also works