MATLAB Answers

Why the given code is not running

1 view (last 30 days)
MINATI
MINATI on 9 Sep 2018
Commented: MINATI on 28 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);
% --------------------------------------------------------------
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];
end
% --------------------------------------------------------------
function u0 = pdex4ic(x);
u0 = [1; 0];
end
% --------------------------------------------------------------
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];
end
% 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')
end

  0 Comments

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 9 Sep 2018
Edited: madhan ravi on 9 Sep 2018
It’s working for me . Make sure you have partial differential equations toolbox by typing ver in your command window.

  19 Comments

MINATI
MINATI on 13 Sep 2018
Hi Walter following error occurs Error using pdepe Too many input arguments.
Error in pdepe (line 6) sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
Walter Roberson
Walter Roberson on 13 Sep 2018
Which MATLAB version are you using? And what shows up for
which pdepe
MINATI
MINATI on 28 Dec 2018
C:\Users\HP\pdepe.m

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!