Solving Problem with "pdepe" Function: Not Enough Inputs

  • Context: MATLAB 
  • Thread starter Thread starter hunt_mat
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting issues with the "pdepe" function in MATLAB, specifically regarding input arguments and function compatibility. Participants are exploring the setup of the function and its components, including the PDE function, initial conditions, and boundary conditions.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses uncertainty about receiving an error related to insufficient input arguments in their implementation of the "pdepe" function.
  • Another participant suggests checking the placement of function pointers and indicates that there may be additional issues beyond just the input arguments.
  • A participant reports an error message indicating that the output dimensions of the function do not match what "pdepe" expects, specifically regarding the variable 'c'.
  • It is proposed that the user should verify that the number and types of input and output arguments in their functions align with the expectations of "pdepe".
  • One participant notes that despite having similar constants as in an example they referenced, they still encounter issues, suggesting that the problem may lie with the value of 'c'.
  • Another participant recommends running the example provided in the link to compare against the user's implementation.
  • A participant expresses frustration with MATLAB's built-in functions, suggesting that writing custom code may be more efficient than navigating the complexities of the built-in functions.
  • One participant shares a successful modification to the code, indicating that using function handles for 'pdefun', 'icfun', and 'bcfun' resolved the issue.
  • Another participant mentions that adding a line to define 'Q' as a function handle also resolved their issues.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the specific cause of the errors, as multiple competing views and suggestions are presented regarding the setup and function compatibility.

Contextual Notes

Participants highlight potential limitations in understanding how "pdepe" interacts with user-defined functions, particularly concerning the expected input and output formats.

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
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
5
Views
12K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K