MATLAB Solving Problem with "pdepe" Function: Not Enough Inputs

  • Thread starter Thread starter hunt_mat
  • Start date Start date
Click For Summary
The discussion revolves around issues with the MATLAB "pdepe" function, specifically regarding insufficient input arguments. Users are encountering errors related to the expected number and types of inputs and outputs for the functions defined within the PDE setup. It is emphasized that the "pdepe" function acts as a wrapper, requiring careful alignment of function signatures with its expectations. Suggestions include verifying the number and types of arguments for each function and comparing with working examples. Ultimately, one user successfully modified the code to resolve the issue by ensuring proper function pointer usage and defining dummy arguments.
hunt_mat
Homework Helper
Messages
1,816
Reaction score
33
TL;DR
I have an error with not enough input parameters
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?
 
Physics news on Phys.org
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,
 
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:
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.
 
Can you try running their example? Sometimes that will give you something to compare against.
 
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.
 
@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.
 
I added the line: Q = @(z) interp1(t,source,z); and it also works
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
Replies
5
Views
12K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K