why the code is not running?
Show older comments
m = 0;
x = linspace(0,1,41);
t = linspace(0,200,10);
sol = pdepe(m,@pdex5pde,@pdex5ic,@pdex5bc,x,t);
n = sol(:,:,1);
c = sol(:,:,2);
figure;
surf(x,t,c);
title('Distribution of fibronectin--c(x)');
xlabel('Distance x');
ylabel('Time t');
figure;
surf(x,t,n);
title('Distribution of ECs--n(x)');
xlabel('Distance x');
ylabel('Time t');
figure;
plot(x,n(end,:));
title('Final distribution of n(x).');
figure;
plot(x,c(end,:));
title('Final distribution of c(x).');
% --------------------------------------------------------------------------
function [c,f,s] = pdex5pde(x,t,u,DuDx)
d = 1e-3;
a = 3.8;
S = 3;
r = 0.88;
N = 1;
c = [1; 1];
f = [ d*DuDx(1) - a*u(1)*DuDx(2)
DuDx(2) ];
s1 = S*r*u(1)*(N - u(1));
s2 = S*(u(1)/(u(1) + 1) - u(2));
s = [s1; s2];
% --------------------------------------------------------------------------
function u0 = pdex5ic(x)
u0 = [1; 0.5];
if x >= 0.3 & x <= 0.6
u0(1) = 1.05 * u0(1);
u0(2) = 1.0005 * u0(2);
end
13 Comments
Walter Roberson
on 20 Dec 2018
What error message are you getting?
madhan ravi
on 20 Dec 2018
Edited: madhan ravi
on 28 Dec 2018
Upload pdex5bc function.
KSSV
on 20 Dec 2018
YOu should specify your error or problem..so that we can help you straight away if possible. Simply copying a part of code will not help us to help you.
MINATI
on 20 Dec 2018
Stephen23
on 20 Dec 2018
@MINATI: please show us the output from this command:
which pdepe -all
MINATI
on 20 Dec 2018
madhan ravi
on 20 Dec 2018
?
Cris LaPierre
on 20 Dec 2018
function pdex4
m = 0;
x = [0 0.005 0.01 0.05 0.1 0.2 0.5 0.7 0.9 0.95 0.99 0.995 1];
t = [0 0.005 0.01 0.05 0.1 0.5 1 1.5 2];
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
figure
surf(x,t,u1)
title('u1(x,t)')
xlabel('Distance x')
ylabel('Time t')
figure
surf(x,t,u2)
title('u2(x,t)')
xlabel('Distance x')
ylabel('Time t')
% --------------------------------------------------------------
function [c,f,s] = pdex4pde(x,t,u,DuDx)
c = [1; 1];
f = [0.024; 0.17] .* DuDx;
y = u(1) - u(2);
F = exp(5.73*y)-exp(-11.47*y);
s = [-F; F];
% --------------------------------------------------------------
function u0 = pdex4ic(x);
u0 = [1; 0];
% --------------------------------------------------------------
function [pl,ql,pr,qr] = pdex4bc(xl,ul,xr,ur,t)
pl = [0; ul(2)];
ql = [1; 0];
pr = [ur(1)-1; 0];
qr = [0; 1];
If I straight borrow pdex4bc and add it to the code provided above, I get the following warnings/errors:
- Warning: Failure at t=1.269576e-02. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.775558e-17) at time t.
- Warning: Time integration has failed. Solution is available at requested time points up to t=1.000000e-02.
- Error using surf (line 71)
- Data dimensions must agree.
madhan ravi
on 20 Dec 2018
Edited: madhan ravi
on 20 Dec 2018
Well thank you Cris for digging into a bit deeper , @Minati just two words doesn’t explain anything , you need to explain more plus you completely ignored the comments which were latter to your comment.
MINATI
on 27 Dec 2018
Walter Roberson
on 27 Dec 2018
Which MATLAB release are you using?
MINATI
on 28 Dec 2018
Walter Roberson
on 28 Dec 2018
Edited: Walter Roberson
on 28 Dec 2018
What shows up for
which -all pdepe
I have tried the example in R2016b, and I tried your code (along with a copy of pdex4bc renamed pdex5bc) in R2016b, and I do not get any problem about too many input arguments for pdepe. I do get the error that Cris mentioned: with that boundary condition, your sol comes out 1 x 41 and you cannot surf() a vector.
You should post the pdex5bc that you are using.
Accepted Answer
More Answers (0)
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!