Solving Problem with "pdepe" Function: Not Enough Inputs

  • MATLAB
  • Thread starter hunt_mat
  • Start date
In summary: I'm starting to think that this may be something to do with the fact that I changed the order of the function calls. I'll try it the other way around and see if that makes a difference.In summary, the code works when I substitute dummy arguments for t, R, X, and source. However, when I add the line Q = @(z) interp1(t,source,z); it fails.
  • #1
hunt_mat
Homework Helper
1,798
33
TL;DR Summary
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
  • #3
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,
 
  • #4
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:
  • #5
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.
 
  • #6
Can you try running their example? Sometimes that will give you something to compare against.
 
  • #7
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.
 
  • #8
@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.
 
  • #9
I added the line: Q = @(z) interp1(t,source,z); and it also works
 

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

What is the "pdepe" function used for?

The "pdepe" function is a built-in MATLAB function that is used for solving partial differential equations (PDEs) numerically. It is particularly useful for solving systems of time-dependent PDEs with initial and boundary conditions.

How do I use the "pdepe" function?

To use the "pdepe" function, you need to provide the function with the necessary inputs, including the PDEs, initial and boundary conditions, and the spatial and temporal domain. You can also specify additional parameters and options to customize the solution process.

Why am I getting an error message saying "Not enough inputs" when using the "pdepe" function?

This error message typically means that you have not provided all the necessary inputs for the function to solve the problem. Make sure you have specified the PDEs, initial and boundary conditions, and the spatial and temporal domain correctly.

Can the "pdepe" function handle non-uniform spatial grids?

Yes, the "pdepe" function can handle non-uniform spatial grids. You can specify the grid points using the "xmesh" input and the corresponding grid spacing using the "meshsize" input. This allows for a more accurate solution for problems with complex geometries.

Are there any limitations to using the "pdepe" function?

While the "pdepe" function is a powerful tool for solving PDEs numerically, it does have some limitations. It is not suitable for solving PDEs with moving boundaries or problems with discontinuous coefficients. Additionally, it may not provide accurate solutions for highly nonlinear problems.

Similar threads

Replies
2
Views
4K
Replies
1
Views
2K
Replies
1
Views
1K
Replies
4
Views
3K
Replies
1
Views
1K
Replies
2
Views
2K
Back
Top