Error in using MATLAB PDEPE function - incorrect matrix sizing
2 ビュー (過去 30 日間)
古いコメントを表示
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
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
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?
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Boundary Conditions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!