📄 fddfebs.m
字号:
function x=fddfebs(a,b,c,d,e,f)
% x=fddfebs(a,b,c,d,e,f)
% This is a function to solve five-diagonal dominantly linear eqations
% system Ax=f.
% input data:
% a is 1xn array with n-2 data, the data is start at
% the 3rd,it is the down second diagonal line data.
% b is 1xn array with n-1 data, the data is start at
% the 2nd,it is the down first diagonal line data.
% c is 1xn array with n data, the data is start at
% the 1st,it is the main diagonal line data.
% d is 1xn array with n-1 data, the data is start at
% the 1st,it is the up first diagonal line data.
% e is 1xn array with n-2 data, the data is start at
% the 1st,it is the up second diagonal line data.
% f is nx1 array with n data, the data is start at
% the 1st,it is the right vector of the equations.
% output data:
% x is the solution of the linear eqations system, it is 1xn.
n=size(f,1);
alph=zeros(1,n);
beta=zeros(1,n);
gamma=zeros(1,n);
z=zeros(1,n);
q=zeros(1,n);
if size(c,2)~=n
error('Error size of data!');
end
alph(1)=c(1);
beta(1)=d(1)/alph(1);
gamma(2)=b(2);
alph(2)=c(2)-gamma(2)*beta(1);
y(1)=f(1)/alph(1);
y(2)=(f(2)-gamma(2)*y(1))/alph(2);
for k=1:n-2
q(k)=e(k)/alph(k);
beta(k+1)=(d(k+1)-gamma(k+1)*q(k))/alph(k+1);
%z(k+2)=a(k+2);
gamma(k+2)=b(k+2)-a(k+2)*beta(k);
alph(k+2)=c(k+2)-a(k+2)*q(k)-gamma(k+2)*beta(k+1);
y(k+2)=(f(k+2)-a(k+2)*y(k)-gamma(k+2)*y(k+1))/alph(k+2);
end
clear alph;clear gamma;clear a;clear b;clear c;clear d;clear e;clear f;
x(n)=y(n);
x(n-1)=y(n-1)-beta(n-1)*x(n);
for k=n-2:-1:1
x(k)=y(k)-q(k)*x(k+2)-beta(k)*x(k+1);
end
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -