Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Name- Omkar Sathe

Class-FYME-Design
Sub-Lab Practice
Roll No.-FYMD1914
Poisson’s Equation
clc;
clear;
tb=input('\n Enter the bottom temperature:');
tt=input('\n Enter the top temperature:');
tl=input('\n Enter the left temperature:');
tr=input('\n Enter the right temperature:');
s=input('\n Enter f(x,y):','s');
f=inline(s);
l=input('\n Enter length:');
w=input('\n Enter height:');
h=input('\n Enter h:');
nofxdata=l/h+1;
nofydata=w/h+1;
a=zeros(nofxdata,nofydata);

for i=2:1:nofydata-1
a(i,1)=tl;
a(i,nofxdata)=tr;
end
for j=2:1:nofxdata-1
a(1,j)=tt;
a(nofydata,j)=tb;
end

n=input('\nEnter no of iteration to perform:');


for k=1:1:n
for i=2:1:nofydata-1
for j=2:1:nofxdata-1
a(i,j)=(a(i+1,j)+a(i-1,j)+a(i,j+1)+a(i,j-1)-h^2*f(j*h,i*h))/4;
end
end
end
a(1,1)= max(tl,tt);
a(1,nofydata)= max(tl,tr);
a(nofxdata,1)= max(tl,tb);
a(nofxdata,nofydata)= max(tr,tb);
a
x=1:1:nofxdata;
y=1:1:nofydata;
surf(x,y,a);
OUTPUT :

You might also like