基函数:.
例如多项式,实际上需要算4x4矩阵A
。
下面是计算代码
a=0;
b=0.5;
c=0;
d=0.5;
dx=1/2;
dy=1/2;
xi=(a+b)/2;
yi=(c+d)/2;
A=zeros(4,4);
basis_1=@(x,y) 1;
basis_2=@(x,y) (x-xi)/(dx/2);
basis_3=@(x,y) (y-yi)/(dy/2);
basis_4=@(x,y) basis_2(x,y).* basis_3(x,y);
f11=@(x,y) basis_1(x,y).*basis_1(x,y);
f12=@(x,y) basis_2(x,y).*basis_1(x,y);
f13=@(x,y) basis_3(x,y).*basis_1(x,y);
f14=@(x,y) basis_4(x,y).*basis_1(x,y);
%2
f21=@(x,y) basis_1(x,y).*basis_2(x,y);
f22=@(x,y) basis_2(x,y).*basis_2(x,y);
f23=@(x,y) basis_3(x,y).*basis_2(x,y);
f24=@(x,y) basis_4(x,y).*basis_2(x,y);
%3
f31=@(x,y) basis_1(x,y).*basis_3(x,y);
f32=@(x,y) basis_2(x,y).*basis_3(x,y);
f33=@(x,y) basis_3(x,y).*basis_3(x,y);
f34=@(x,y) basis_4(x,y).*basis_3(x,y);
%4
f41=@(x,y) basis_1(x,y).*basis_4(x,y);
f42=@(x,y) basis_2(x,y).*basis_4(x,y);
f43=@(x,y) basis_3(x,y).*basis_4(x,y);
f44=@(x,y) basis_4(x,y).*basis_4(x,y);
%%%%%%%%%%%%%%%%%%%%%%%
A(1,1)=single2D_Gauss(a,b,c,d,f11,3);
A(1,2)=single2D_Gauss(a,b,c,d,f12,3);
A(1,3)=single2D_Gauss(a,b,c,d,f13,3);
A(1,4)=single2D_Gauss(a,b,c,d,f14,3);
%
A(2,1)=single2D_Gauss(a,b,c,d,f21,3);
A(2,2)=single2D_Gauss(a,b,c,d,f22,3);
A(2,3)=single2D_Gauss(a,b,c,d,f23,3);
A(2,4)=single2D_Gauss(a,b,c,d,f24,3);
%
A(3,1)=single2D_Gauss(a,b,c,d,f31,3);
A(3,2)=single2D_Gauss(a,b,c,d,f32,3);
A(3,3)=single2D_Gauss(a,b,c,d,f33,3);
A(3,4)=single2D_Gauss(a,b,c,d,f34,3);
%
A(4,1)=single2D_Gauss(a,b,c,d,f41,3);
A(4,2)=single2D_Gauss(a,b,c,d,f42,3);
A(4,3)=single2D_Gauss(a,b,c,d,f43,3);
A(4,4)= single2D_Gauss(a,b,c,d,f44,3);
A
%single2D_Gauss算的是单元内部函数f的积分(矩形单元的积分公式,建议自己编写!!)
上述定义,发现很长,如果能够进行索引,用循环可大大省下来... 如何给在句柄结构定义的函数进行索引?????(用元胞?)事实上,如果我们实现用句柄定义了二元函数,并且想把此定义好的句柄函数放入到用于计算高斯积分定义的函数时候.