% The 8 fields "XXX" below should be specified % % This is a Matlab script FEM.m which produces a 3d plot of the solution to the Dirichlet problem, which it calculates using the finite element method which mesh size 1/L and using bilinear elements on squares. It requires Matlab programs h1.m and h2.m for the lower and upper boundaries of the domain and f.m for (an extension of) the boundary data % % L= XXX ; % mesh size =1/L a= XXX ; % x-coordinate for left end of domain b= XXX ; % x-coordinate for right end of domain % Required functions: % lower boundary curve y=h1(x) % upper boundary curve y=h2(x) % extension of boundary Dirichlet data z=f(x,y) dx= (b-a)/(L+1); y1= zeros(L,1); y2=zeros(L,1); for k=1:L y1(k)=floor(h1(a+k*dx)/dx); %lower boundary y1= integer valued scale y2(k)=floor(h2(a+k*dx)/dx); %upper boundary y2= integer valued scale end ydiff= y2-y1+1; %y1= integer valued length of vertical cross section N=sum(ydiff); % total number of trial functions M=zeros(N,N); % stiffness matrix M G=zeros(N,1); % source vector G F=zeros(N,1); % extension of Dirichlet data vector F i1=0; % start index of current column in the domain for n=1:L % column in the domain i2=i1+ydiff(n); % start index of next column in the domain for j=1:ydiff(n) % neighbours in the stiffness matrix if j