too many input arguments when using pdepe
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, I meet a problem when using pdepe, and I tried many ways but can't solve this. Could you help me with this?
I got errors like 'too many/ not enough argument when using pdepe' when modifying
sol = pdepe(m,@(t,u) wave_ode1(x,t,u,dudx,p),@pdeic2,@pdebc2,x);
my code is below:
Thank you!
clear all
close all
hx = 0.1;%need try 0.01
L = 10;%
x = 0:hx:L;
t = [0:0.1:200];
Da=0.1;
Db=10;
m = 0;
p=[Da;Db];
sol = pdepe(m,@(t,u) wave_ode1(x,t,u,dudx,p),@pdeic2,@pdebc2,x);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
surf(x,t,u1)
title('u_1(x,t)')
xlabel('Distance x')
ylabel('Time t')
surf(x,t,u2)
title('u_2(x,t)')
xlabel('Distance x')
ylabel('Time t')
function [c,f,s] = wave_ode1(x,t,u,dudx,p) % Equation to solve
c = [1; 1];
f = [Da; Db] .* dudx;
y = u(1) - u(2);
F = exp(5.73*y)-exp(-11.47*y);
s = [-F; F];
end
function u0 = pdeic2(x) % Initial Conditions
u0 = [1; 0];
end
function [pl,ql,pr,qr] = pdebc2(xl,ul,xr,ur,t) % Boundary Conditions
pl = [0; ul(2)];
ql = [1; 0];
pr = [ur(1)-1; 0];
qr = [0; 1];
end
댓글 수: 0
채택된 답변
Torsten
2022년 3월 25일
sol = pdepe(m,@(x,t,u,dudx) wave_ode1(x,t,u,dudx,p),@pdeic2,@pdebc2,x,t);
function [c,f,s] = wave_ode1(x,t,u,dudx,p) % Equation to solve
c = [1; 1];
f = [p(1); p(2)] .* dudx;
y = u(1) - u(2);
F = exp(5.73*y)-exp(-11.47*y);
s = [-F; F];
end
댓글 수: 5
추가 답변 (1개)
Walter Roberson
2022년 3월 25일
sol = pdepe(m,@(t,u) wave_ode1(x,t,u,dudx,p),@pdeic2,@pdebc2,x);
pdepe needs m, then three function handles, then x mesh, and then time span.
You have m, then three function handles, then x mesh... and no time span.
댓글 수: 2
Walter Roberson
2022년 3월 25일
The pdefun (first function handle) will be passed x, t, u, dudx. Your @(t,u) function handle expects to receive only two parameters.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!