Académique Documents
Professionnel Documents
Culture Documents
Programa: f1.m
function ux0=f1(x)
ux0=10;
Programa: f2.m
function ux4=f2(x)
ux4=160;
Programa: f3.m
function u0y=f3(y)
u0y=70;
Programa: f4.m
function u4y=f4(y)
u4y=0;
Programa: stard.m
U=dirich('f1','f2','f3','f4',4,4,0.5,0.01,10)
mesh(U)
title('SOLUCION DE LA EQUACION DE LAPLACE','COLOR','b','FontSize',10)
xlabel('x','FontSize',10)
ylabel('y','FontSize',10)
zlabel('U(x,y)','FontSize',10)
ejex=0:0.5:4;
ejey=0:0.5:4;
>> stard
U=
Columns 1 through 8
35.0000
160.0000
70.0000
78.6069
70.0000
70.0000
70.0000
70.0000
70.0000
70.0000
40.0000
Column 9
80.0000
0
0
0
0
0
0
0
5.0000
99.8307
82.1193
68.7723
57.3437
45.5114
30.5746
10.0000
102.5277
81.9252
65.6796
52.0235
39.1401
25.3956
10.0000
99.6026
77.3747
59.9981
45.9310
33.6304
21.8694
10.0000
90.9669
67.9727
51.0077
38.0716
27.5809
18.4533
10.0000
74.4841
52.5414
37.9885
27.7672
20.1676
14.3628
10.0000
45.7030
29.7206
20.6377
14.8413
10.9600
8.8306
10.0000
Programa: f1.m
function ux0=f1(x)
ux0=10;
Programa: f2.m
function ux4=f2(x)
ux4=100;
Programa: f3.m
function u0y=f3(y)
u0y=0;
Programa: f4.m
function u4y=f4(y)
u4y=100;
Programa: stard.m
U=dirich('f1','f2','f3','f4',50,50,0.5,0.01,10)
mesh(U)
title('SOLUCION DE LA EQUACION DE LAPLACE','COLOR','b','FontSize',10)
xlabel('x','FontSize',10)
ylabel('y','FontSize',10)
zlabel('U(x,y)','FontSize',10)
ejex=0:1:50;
ejey=0:1:50;
>> stard
U=
Columns 1 through 8
50.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000
100.0000
0 49.9736 69.8411 79.4663 85.2049 89.3989 93.0281 96.5149
0 30.0553 49.9109 62.7956 71.9358 79.3521 86.1928 93.0281
0 20.3655 36.9639 49.8563 60.3730 69.8651 79.3521 89.3989
0 14.5877 27.7797 39.3151 49.8380 60.3730 71.9358 85.2049
0 10.5185 20.3622 29.8455 39.3151 49.8563 62.7956 79.4663
0 6.6391 13.6292 20.3622 27.7797 36.9639 49.9109 69.8411
0 3.1829 6.6391 10.5185 14.5877 20.3655 30.0553 49.9736
0
0
0
0
0
0
0
0
Column 9
100.0000
100.0000
100.0000
100.0000
100.0000
100.0000
100.0000
100.0000
50.0000
u(x,4) = 190
Programa: dirich.m
function U = dirich( f1,f2,f3,f4,a,b,h,tol,max1 )
n=fix(a/h)+1;
m=fix(b/h)+1;
ave=(a*(feval(f1,0)+feval(f2,0))...
+b*(feval(f3,0)+feval(f4,0)))/(2*a+2*b);
U=ave*ones(n,m);
%condiciones de contorno
U(1,1:m)=feval(f3,0:h:(m-1)*h)';
U(n,1:m)=feval(f4,0:h:(m-1)*h)';
U(1:n,1)=feval(f1,0:h:(n-1)*h);
U(1:n,m)=feval(f2,0:h:(n-1)*h);
U(1,1)=(U(1,2)+U(2,1))/2;
U(1,m)=(U(1,m-1)+U(n,2))/2;
U(n,1)=(U(n-1,1)+U(n,2))/2;
U(n,m)=(U(n-1,m)+U(n,m-1))/2;
% Parametro de sobrerrelajacion
w=4/(2+sqrt(4-(cos(pi/(n-1))+cos(pi/(m-1)))^2));
err=1;
cnt=0;
while((err>tol)&(cnt<=max1))
err=0;
for j=2:(m-1),
for i=2:(n-1),
relx=w*(U(i,j+1)+U(i,j-1)+U(i+1,j)+U(i-1,j)...
-4*U(i,j))/4;
U(i,j)=U(i,j)+relx;
if(err<=abs(relx)), err=abs(relx);
end
end
end
cnt=cnt+1;
end
U=flipud(U');
end
u(4,y) = 0
Programa: f1.m
function ux0=f1(x)
ux0=30;
Programa: f2.m
function ux4=f2(x)
ux4=190;
Programa: f3.m
function u0y=f3(y)
u0y=90;
Programa: f4.m
function u4y=f4(y)
u4y=0;
Programa: stard.m
U=dirich('f1','f2','f3','f4',4,4,0.5,0.01,10)
mesh(U)
title('SOLUCION DE LA EQUACION DE LAPLACE','COLOR','b','FontSize',10)
xlabel('x','FontSize',10)
ylabel('y','FontSize',10)
zlabel('U(x,y)','FontSize',10)
ejex=0:0.5:4;
ejey=0:0.5:4;
>> stard
U=
Columns 1 through 8
45.0000
190.0000
90.0000
93.7802
90.0000
90.0000
90.0000
90.0000
90.0000
90.0000
60.0000
Column 9
95.0000
0
0
0
0
0
0
0
15.0000
122.7383
103.1129
88.6231
76.6373
64.7702
50.0455
30.0000