Fix the error in code.

I am trying to solve equation
%%%%u(∂u/∂t)=∂^2u/∂z^2
% Bc's
%%%%C(z,0) =0, z>0; ∂u(0,t)/∂z =-b, t>0; C(1,t) = 0, t>0;
I have attached the code and resulting figure. CAn some body fix this issue.
function pdex11
m=0;
x = linspace(0,1,100)
t = linspace(0,1,33)
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1)
surf(x,t,u)
title('Numerical solution.')
xlabel('Distance x')
ylabel('Time t')
% A solution profile can also be illuminating.
figure
plot(x,u(end,:))
title('Solution at t = 2')
xlabel('Distance x')
ylabel('u(x,2)')
function u0 = pdex1ic(x)
%u0 = 1;
% --------------------------------------------------------------
u0 = 0;
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
% pl = u1;
% ql = 0;
% pr = 1;
% qr = 1;
pl = -1;
ql = 1;
pr = ur;
qr = 0;
function [c,f,s] = pdex1pde(x,t,u,DuDx)
% c = 1;
% f = (1/u)*DuDx;
% s = 0;
c = u;
f = DuDx;
s = 0;

5 件のコメント

Stephen23
Stephen23 2016 年 6 月 24 日
What is the error? If you actually tell us what the code is doing wrong then we can help you to fix it. otherwise we have to use our mind reading powers, which are not always so reliable.
John D'Errico
John D'Errico 2016 年 6 月 24 日
編集済み: John D'Errico 2016 年 6 月 24 日
Please, stop adding answers every time you want to add information. I've moved your comments into comments, where they belong.
John D'Errico
John D'Errico 2016 年 6 月 24 日
編集済み: John D'Errico 2016 年 6 月 24 日
Moved to a comment (from Cute Doll):
1st error This DAE appears to be of index greater than 1.
2nd error [y,yp,f0,dfdy,nFE,nPD,Jfac] = daeic12(odeFcn,odeArgs,t,ICtype,Mt,y,yp0,f0...
John D'Errico
John D'Errico 2016 年 6 月 24 日
Moved to a comment:
I am trying to solve equation u(∂u/∂t)=∂^2u/∂z^2 Bc's C(z,0) =0, z>0; ∂u(0,t)/∂z =-b, t>0; C(1,t) = 0, t>0;
output is show in attached figure.
Bill Greene
Bill Greene 2016 年 6 月 24 日
You submitted this same question to the MATLAB newsgroup using the user name "kanwal shahzadi" and received an answer that correctly identified the problem with your code. What is your purpose in making up a new fictitious user name and posting the question again here in MATLAB Answers?

サインインしてコメントする。

回答 (1 件)

Cute Doll
Cute Doll 2016 年 6 月 24 日

0 投票

@David Sanchez @Walter Roberson

1 件のコメント

Walter Roberson
Walter Roberson 2016 年 6 月 24 日
I am relatively sure that my username is not an Answer to questions about DAE.

サインインしてコメントする。

カテゴリ

質問済み:

2016 年 6 月 24 日

コメント済み:

2016 年 6 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by