whats wrong with my code?

조회 수: 12 (최근 30일)
Shangeetha Mahendran
Shangeetha Mahendran 2018년 12월 3일
댓글: Shangeetha Mahendran 2018년 12월 4일
function ped1
sol =pdepe(m,@pdefun,@pdeic,@pdebc,xmesh,tspan);
u=sol(:,:,1);
function [c,f,s]= pdefun(x,t,u,DuDx)
c = V/D;
f = DuDx;
s=0;
end
ped1
Undefined function or variable 'V'.
Error in pdefun (line 2)
c = V/D;
Error in pdepe (line 246)
[c,f,s] = feval(pde,xi(1),t(1),U,Ux,varargin{:});
Error in ped1 (line 27)
sol =pdepe(m,@pdefun,@pdeic,@pdebc,xmesh,tspan);
  댓글 수: 2
Stephen23
Stephen23 2018년 12월 3일
Before this line:
c = V/D;
Where are V and D defined?
Shangeetha Mahendran
Shangeetha Mahendran 2018년 12월 3일
I have defined in ped1
function ped1
m=1;
R=2.2e-4; %radius of lumen (m)
dm = 13.04e-6; % TM thickness (m)
r1 =R + dm; %radius of outer surface of membrane (m)
L=1; %height of the membrane (m)
Q = 6.5e-9; %volumetric flow rate
D=1.76e-9;
RT = 2477.6;
H = 1.62; %Henry's law constant Pam^3/mol
u0= 285.1;
xn = 10; % grid-steps channel x-axis(radius side)
xmesh = linspace(0,R,xn);
tspan =linspace(0,L,10); %counter point of length% spatial solution domain (m)
dx = 1/(xn-1);
x = [xmesh];
V = Q/3.14/R^2;
%U_z =zeros(1,xn);
%for ii=1:xn
%U_z(ii) =2*U_a *(1- x(ii)^2/R^2);
%end
sol =pdepe(m,@pdefun,@pdeic,@pdebc,xmesh,tspan);
u=sol(:,:,1);
surf(x,t,u)
xlabel('radi')
ylabel('height')
figure
plot(x,u(end,:))
xlabel('radi')
ylabel('concentration')
end
function [c,f,s]= pdefun(x,t,u,DuDx)
c = V/D;
f = DuDx;
s=0;
end
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,t)
pl=0;
ql=1;
pr= u0 *(1-0.6*x/R)* H / RT / x / log (r1/R);
qr=1;
end
function u0 = pdeic(x)
u0 =285.1;
end

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

채택된 답변

Stephen23
Stephen23 2018년 12월 3일
편집: Stephen23 2018년 12월 3일
Make pdefun and pdebc nested functions by defining them inside of ped1:
function ped1()
...
V = ...
D = ...
R = ...
...
function [...]= pdefun(...)
...
V/D
...
end
function [...] = pdebc(...)
...
end
end
  댓글 수: 5
Stephen23
Stephen23 2018년 12월 4일
편집: Stephen23 2018년 12월 4일
"in pdefun; is that possible to use array for the term "c" nstead of constant?"
MATLAB does not have any "constant" class, so it is not clear what you mean. Perhaps you mean that c is scalar?
In any case, the pdepe help states the the first output c should be a column vector. Given that both V and D are scalars, it is not clear what you expect c to be. Please show an example.
Shangeetha Mahendran
Shangeetha Mahendran 2018년 12월 4일
function [c,f,s]= pdefun(x,t,u,DuDx)
c = V/D;
f = DuDx;
s=0;
end
"c" is from this function.
if v is a column vector and t is the raw matrix is that possible to solve with pdepe

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 PDE Solvers에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by