Matlab code for boundary condition

What is the matlab code for below the boundary conditon?
(i) x=0, y=0
(ii) x=0, dy/dx +dz/dx =0
(iii) t=0, x=infinity, y=1, z=c

4 comentarios

Torsten
Torsten el 27 de Jun. de 2019
Depends on the numerical program for which you try to implement these conditions.
Salai Mathiselvi Salai Mathiselvi
Salai Mathiselvi Salai Mathiselvi el 27 de Jun. de 2019
Editada: Salai Mathiselvi Salai Mathiselvi el 27 de Jun. de 2019
y''(x,t)-y^2*y'(x,t)+a*z(x,t)-c*y(x,t)-y'(t)=0
z''(x,t)-y^2*z'(x,t)-a*z(x,t)+c*y(x,t)-z'(t)=0
Boundary condition
(i) x=0, y=0
(ii) x=0, dy/dx +dz/dx =0
(iii) t=0, x=infinity, y=1, z=b
What is the matlab code for this equation?
Torsten
Torsten el 27 de Jun. de 2019
What is the difference between y'(x,t) and y'(t) ?
Same for z.
According to which independent variable do you differntiate when you write y', y'', z', z'' ?
Torsten
Torsten el 27 de Jun. de 2019
Editada: Torsten el 27 de Jun. de 2019
Salai Mathiselvi Salai Mathiselvi's comment moved here:
d^2y/dx^2-y^2*dy/dx+a*z-c*y-dy/dt=0,
d^2z/dx^2-y^2*dz/dx+a*z-c*y-dz/dt=0
Boundary condition
(i) x=0, y=0
(ii) x=0, dy/dx +dz/dx =0
(iii) t=0, x=infinity, y=1, z=b
What is the matlab code for this equation?

Iniciar sesión para comentar.

Respuestas (1)

Torsten
Torsten el 27 de Jun. de 2019

0 votos

So you mean
at x=0, you have y = 0 and dy/dx + dz/dx
at x=infinity, you have y=1 and z = b
and at t = 0, you have
y = 1, z = b
for all x in [0;infinity] ?
If you have numerical values for a, b and c, read the documentation of "pdepe".
It will show you how to write the MATLAB code for your equations.

3 comentarios

Matlab Program
function pdex4
m = 2;
x = linspace(0,5);
t = linspace(0,1000);
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x, t);
u1 = sol(:, :, 1);
u2 = sol(:, :, 2);
% A solution profile can also be illuminating.
figure
plot(x,u1(end,:))
% A solution profile can also be illuminating.
figure
plot(x,u2(end,:))
%--------------------------------------------------------------------
function [c, f, s] = pdex4pde(x,t,u,DuDx)
c = [1;1];
f = [1;1].*DuDx;
k = 0.1;
k1 =0.5;
F=k*u(2)-k1*u(1);
F1=-k*u(2)+k1*u(1);
s = [F;F1];
%---------------------------------------------------------------------
function u0 = pdex4ic(x)
u0 =[1;1];
%---------------------------------------------------------------------
function [pl, ql, pr,qr] = pdex4bc(xl,ul,xr,ur,t)
pl = [0;ul(1)];
ql = [1;1];
pr = [ur(1)-1;ur(2)];
qr = [1;1];
Is it correct? if not how should i correct this for different values of 't'?
Torsten
Torsten el 27 de Jun. de 2019
Editada: Torsten el 27 de Jun. de 2019
  1. m = 2 is wrong.
  2. You didn't include the terms -y^2*dy/dx and -y^2*dz/dx in the equations.
  3. Your boundary conditions settings are all wrong.
To include the boundary condition dy/dx + dz/dx = 0 at x=0 for "pdepe", you will have to rewrite your system of equations in terms of y and u:=y+z. This leads to
d^2y/dx^2-y^2*dy/dx+a*(u-y)-c*y-dy/dt=0,
d^2u/dx^2-y^2*du/dx-du/dt = 0
Best wishes
Torsten.
Thank you very much sir. Your anwer was very helpful my work.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by