function [A,B,C,r]=init_matrix(a,b,c,N,h);
%initializam blocurile matricei sistemului si matricea coloana a %termenilor liberi
%initializam termenii liberi
r1=zeros(N-1,1);r2=zeros(N-1,1);r3=zeros(N-1,1);
for i=1:N-1
   r1(i)=-((a(i+1)-a(i))/h-(b(i+1)+b(i))/2);
   r2(i)=-((b(i+1)-b(i))/h-(c(i+1)+c(i))/2);
   r3(i)=-((c(i+1)-c(i))/h+(a(i+1)+a(i))*(c(i+1)+c(i))/8);
end;
r(:,1)=[-a(1);-b(1);r2(1)];
for i=2:(N-1)
   r(:,i)=[r1(i-1);r3(i-1);r2(i)];
end;
r(:,N)=[r1(N-1);r3(N-1);1-b(N)];

%initializare blocurile A
A(:,:,1)=[1 0 0 ;0 1 0;0 -1/h -0.5];
for i=1:(N-2)
   A(:,:,i+1)=[1/h -0.5 0;(c(i+1)+c(i))/8 0 (1/h)+((a(i+1)+a(i))/8);0 -1/h -1/2];
end
A(:,:,N)=[1/h -1/2 0;(c(N)+c(N-1))/8 0 (1/h)+((a(N)+a(N-1))/8);0 1 0];

%initializare blocurile B
B(:,:,1)=zeros(3,3);
for i=1:(N-1)
   B(:,:,i+1)=[-1/h -1/2 0;(c(i+1)+c(i))/8 0 (-1/h)+((a(i+1)+a(i))/8);0 0 0];
end

%initializare blocurile C
C(:,:,1)=zeros(3,3);
for i=1:(N-1)
   C(:,:,i)=[0 0 0;0 0 0;0 1/h -0.5];
end
