You are on page 1of 2

NAME-Netke Krushna Macchindra

BRANCH-Mech Div-B
ROLL NO-06

PDE USING PARABOLIC EQUATION


Clc

fprintf('Program for parabolic Equation-');


f=inline('2*x+1');
x0=input('\nEnter the initial value of x=');
xn=input('\nEnter the final value of x=');
t0=input('\nEnter the initial value of t=');
tn=input('\nEnter the value of t=');
h=input('\nEnter the value of h=');
k=input('\nEnter the value of k=');
u1=input('\nEnter the value of u,for all t & at x0=');
u2=input('\nEnter the value of u,for all t % at xn=');
n=(xn-x0)/h;
n=round(n);

for i=1:n+1
x1(i)=(x0+(h*(i-1)));
end
m=(tn-t0)/k;
m=round(m);

for i=1:m+1
t1(i)=(t0+(k*(i-1)));
end
for r=1:m+1
x(r,1)=u1;
x(r,n+1)=u2;
end
for c=2:n
x(1,c)=f(x0+(h*(c-1)));
end
v=(k/(h*h));
for r=2:m+1
for c=2:n
x(r,c)=v*(x(r-1,c-1))+(1-2*v)*(x(r-1,c))+v*(x(r-1,c+1));
end
end
forr=m+1:-1:1
for c=1:n+1
fprintf('\t%f',x(r,c));
end
fprintf('\n');

Output
Program for parabolic Equation-

Enter the initial value of x=0

Enter the final value of x=0.5

Enter the initial value of t=0

Enter the value of t=0.03

Enter the value of h=0.1

Enter the value of k=0.01

Enter the value of u,for all t & at x0=1

Enter the value of u,for all t % at xn=1

forr =

4 3 2 1

1.000000 1.200000 0.400000 2.600000 -0.200000 1.000000

>>

You might also like