why do i receive this error please help to rectify the error.

1 view (last 30 days)
the boundary conditions are
a'(0)=0 a(1)=1
b(0)=0 b(1)=0
function steady
m = 0;
x = linspace(0,1);
t = linspace(0,10000);
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
u1 = sol(:,:,1);
u2= sol(:,:,2);
%figure
plot(x, u2(end,:),'m')
hold on
%title('u1(x, t)')
%xlabel('Distance x')
%ylabel('u1(x,t)')
%figure
% --------------------------------------------------------------
function [c,f,s] = pdex4pde(~,~,u,DuDx)
phi=0.001;ks=1;kp=1;al=0.1; %These parameter values are used in Fig.2
c = [1;1];
f = [1;1].* DuDx;
F1=phi.^2.*u(1)./(1+(u(2)./kp)+u(1).*(1+(u(1)./ks)));
F2=-al.*phi.^2.*u(1)./(1+(u(2)./kp)+u(1).*(1+(u(1)./ks)));
s = [F1;F2];
% --------------------------------------------------------------
function u0 = pdex4ic(~)
u0 = [1; 1];
% --------------------------------------------------------------
function [pl,ql,pr,qr] = pdex4bc(~,~,ul,ur,~)
pl = [0;ul(2)];
ql = [1;0];
pr = [ur(1)-1;ur(2)];
qr = [0;0];
%qr = [0; bi*(1-ur(2))];
Error
Index exceeds the number of array elements (1).
Error in steady>pdex4bc (line 28)
pl = [0;ul(2)];
Error in pdepe (line 250)
[pL,qL,pR,qR] = feval(bc,xmesh(1),y0(:,1),xmesh(nx),y0(:,nx),t(1),varargin{:});
Error in steady (line 5)
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);

Answers (1)

Walter Roberson
Walter Roberson on 11 Aug 2022
Moved: Sabin on 18 May 2023
function [pl,ql,pr,qr] = pdex4bc(~,~,ul,ur,~)
ul is passed as the second parameter to pdex4bc, not the third entry.

Categories

Find more on MATLAB 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!