Problem with pdepe

  • MATLAB
  • Thread starter hunt_mat
  • Start date
  • Tags
    pdepe
  • #1
hunt_mat
Homework Helper
1,741
25

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?
 

Answers and Replies

  • #3
hunt_mat
Homework Helper
1,741
25
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
11,823
5,445
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
hunt_mat
Homework Helper
1,741
25
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
11,823
5,445
Can you try running their example? Sometimes that will give you something to compare against.
 
  • #7
hunt_mat
Homework Helper
1,741
25
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
DrClaude
Mentor
7,339
3,521
@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
hunt_mat
Homework Helper
1,741
25
I added the line: Q = @(z) interp1(t,source,z); and it also works
 

Related Threads on Problem with pdepe

  • Last Post
Replies
4
Views
1K
Replies
2
Views
1K
Replies
2
Views
2K
Top