Error in using MATLAB PDEPE function - incorrect matrix sizing

조회 수: 2 (최근 30일)
Sarah Snader
Sarah Snader 2018년 4월 14일
댓글: Torsten 2018년 4월 16일
Hello!
I am having some issues modifying the code on Matlab Example 2 pdex4 function on the PDEPE help page. I believe the problem is incorrectly sized matrices, but I am not sure where I should be using '.*' vs'*'.
function [x,t,u1, u2]=pdex4attempt(dummy)
close all;
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];
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
% --------------------------------------------------------------
function [c,f,s] = pdex4pde(x,t,u,DuDx)
Pe=1000;
gamma=2;
phi=0.4;
c = [Pe; 1];
f = [DuDx-Pe.*u(1); 0];
F=(gamma.*u(1)-u(2));
s = [-((1-phi)/phi)*F*Pe; F];
end
% --------------------------------------------------------------
function u0 = pdex4ic(x)
u0 = [0; 0];
end
% --------------------------------------------------------------
function [pl,ql,pr,qr] = pdex4bc(xl,ul,xr,ur,t)
Pe=1000;
beta=0;
pl = [ul(1); 0];
ql = [0; 0];
pr = [-beta+Pe.*ur(1); 0];
qr = [1; 0];
end
  댓글 수: 1
Torsten
Torsten 2018년 4월 16일
pdepe is designed to solve parabolic-elliptic PDEs, not a mixture of ODEs and PDEs as in your case.

댓글을 달려면 로그인하십시오.

답변 (1개)

Bill Greene
Bill Greene 2018년 4월 14일
The line
f = [DuDx-Pe.*u(1); 0];
is creating a variable f with three rows rather than the correct two rows because DuDx, itself, is dimensioned 2x1. Since you didn't post your equations it is impossible to say what is the correct expression. Do you perhaps want DuDx(1) instead of just DuDx?

카테고리

Help CenterFile Exchange에서 Boundary Conditions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by