Guass PDF

You might also like

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

4/30/23 7:51 PM G:\Matlab\bin\projets\Untitled.

m 1 of 1

clc
clear all
a=0.2;b=0.8;h=0.2;tol=0.5;
ud=1;ul=1;x=[a:h:b];y=[a:h:b];
uold=zeros(4,4); k=1;ug=zeros(4,4);
while (k>0)
for j=1:4
for i=1:4
if j==1
us=ud;
else us=ug(i,j-1);
end
if i==4
ue=exp(2*y(i));
else ue=ug(i+1,j);
end
if i==1
uw=ul;
else uw=ug(i-1,j);
end

if j==4
un=exp(x(i));
else un=ug(i,j+1);
end
unew(i,j)=(us+ue+un+uw)/4;
ug(i,j)=unew(i,j);
end
end
k=0;
for j=1:4
for i=1:4
error(i,j)=abs( (unew(i,j)-uold(i,j))/ unew(i,j));
if error(i,j)>tol
k=k+1
uold=unew;
end
end
end
end
table (unew, error)

You might also like