Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: pdepe solver: pass extra parameters K3
Replies: 0

 Zuhair Posts: 10 Registered: 10/18/13
pdepe solver: pass extra parameters K3
Posted: Jul 14, 2014 2:55 AM

Hi all,

I am trying to solve my model by passing one additional parameters K3 into pdepe solver. I follow the approach discussed by Jacek Kierzenka in this this forum:

But I keep getting error message: "Error using vertcat. Dimensions of matrices being concatenated are not consistent". Can anyone please help me to point out what is my mistake? Here is my code:

function [pl,ql,pr,qr] = bc2(xl,ul,xr,ur,t,K3)
pl = [0; 0; 0];
ql = [1; 1; 1];
pr = [0; 0; 0];
qr = [1; 1; 1];
----------------------------------------------------
function [c,b,s] = eqn2(x,t,u,DuDx,K3)
global a m1 b2 ic1 ic2 ic3
c = [1; 1; 1]; % coefficiet of time derivatives
b = [0.001; 0.001; 0.001].* DuDx; % diffusion terms
s = [...
u(1)*(1-(u(1)/(m1*x))-(a)*(u(2)/(m1*x))-(a)*(u(3)/(m1*x)));...
u(2)*(1-(u(2)/b2)-(a)*(u(1)/b2)-(a)*(u(3)/b2));...
u(3)*(1-(u(3)/(K3))-(a)*(u(1)/(K3))-(a)*(u(2)/(K3)))];
------------------------------------------------------
function value = initial2(x,K3);
global a m1 b2 ic1 ic2 ic3
value = [ic1.*(m1*x); ic2.*b2; ic3*K3];
-------------------------------------------------------
global a m1 b2 ic1 ic2 ic3

a = 0.8;
m1 = 10;
b2 = 40;

ic1 = 0.5;
ic2 = 0.9;
ic3 = 0.3;
m = 0;
x = linspace(0,10,1001); %2001
K3 = 20.*x-80;
K3(1:401) = 0;
t = 0:1:1000; % 1000
sol = pdepe(m,@eqn2,@initial2,@bc2,x,t,[],K3);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
u3 = sol(:,:,3);

Cheers
Zuhair