x=[];
h0=1;
M=4;
N=M+1;
x(1)=0;
x(N)=x(1)+h0*M;
x=x(1):h0:x(N)
A=zeros(N);
A(1,1)=-2*(5*(x(N)*h0)^2/12+1);
A(N,N)=-2*(5*(x(1)*h0)^2/12+1);
A(1,2)=1-(x(M)*h0)^2)/12;
A(N,M)=1-(x(2)*h0)^2)/12;
B=zeros(N);
B(1,1)=B(N,N)=-10*(h0^2)/6;
B(1,2)=B(N,M)=-(h0^2)/6;
for i=2:M
B(i,i)=-10*(h0^2)/6;
B(i,i-1)=B(i,i+1)=-(h0^2)/6;
A(i,i)=-2*(5*(x(N+1-i)*h0)^2/12+1);
A(i,i+1)=1-(x(N-i)*h0)^2)/12;
A(i,i-1)=1-(x(N+2-i)*h0)^2)/12;
end
A
B
h0=1;
M=4;
N=M+1;
x(1)=0;
x(N)=x(1)+h0*M;
x=x(1):h0:x(N)
A=zeros(N);
A(1,1)=-2*(5*(x(N)*h0)^2/12+1);
A(N,N)=-2*(5*(x(1)*h0)^2/12+1);
A(1,2)=1-(x(M)*h0)^2)/12;
A(N,M)=1-(x(2)*h0)^2)/12;
B=zeros(N);
B(1,1)=B(N,N)=-10*(h0^2)/6;
B(1,2)=B(N,M)=-(h0^2)/6;
for i=2:M
B(i,i)=-10*(h0^2)/6;
B(i,i-1)=B(i,i+1)=-(h0^2)/6;
A(i,i)=-2*(5*(x(N+1-i)*h0)^2/12+1);
A(i,i+1)=1-(x(N-i)*h0)^2)/12;
A(i,i-1)=1-(x(N+2-i)*h0)^2)/12;
end
A
B
Comments
Post a Comment