syms x y N h
format rat
N=2
h=4;
H=[(1+2*N*x/h)*(1+2*N*y/h)/4;(1-2*N*x/h)*(1+2*N*y/h)/4;(1-2*N*x/h)*(1-2*N*y/h)/4;(1+2*N*x/h)*(1-2*N*y/h)/4]; %存储函数
for i=1:4
for j=1:4
f(i)=diff(H(i,1),x); %求偏导
f2(i)=diff(H(i,1),y);
f(j)=diff(H(j,1),x);
f2(j)=diff(H(j,1),y);
F(i,j)=f(i)*f(j)+f2(i)*f2(j);
S(i,j)=int(int(F(i,j),x,-h/(2*N),h/(2*N)),y,-h/(2*N),h/(2*N)); %积分
D1(1,i)=int(int(f(i),y,-h/(2*N),h/(2*N)),x,-h/(2*N),h/(2*N))/(h*h/(N*N));
D2(1,i)=int(int(f2(i),y,-h/(2*N),h/(2*N)),x,-h/(2*N),h/(2*N))/(h*h/(N*N));
end
end
G1=h*h/(N*N)*D1'*D1;
G2=h*h/(N*N)*D2'*D2;
G1=double(G1);
G2=double(G2);
S=double(S);
Gh=[G1 zeros(4);zeros(4) G2];
Sh=[S zeros(4);zeros(4) S];
E=eig(Gh,Sh);
Lambda=min(E(find(E~=0)));
计算程序是通过N的值来算相应的Lambda值,N=2,4,8然后画图,我写的程序它中间有个符号矩阵转数值矩阵,导致中图的G1,G2S矩阵含变量时用double()转换错误,上面是N=2的,求帮忙看看,谢谢。
format rat
N=2
h=4;
H=[(1+2*N*x/h)*(1+2*N*y/h)/4;(1-2*N*x/h)*(1+2*N*y/h)/4;(1-2*N*x/h)*(1-2*N*y/h)/4;(1+2*N*x/h)*(1-2*N*y/h)/4]; %存储函数
for i=1:4
for j=1:4
f(i)=diff(H(i,1),x); %求偏导
f2(i)=diff(H(i,1),y);
f(j)=diff(H(j,1),x);
f2(j)=diff(H(j,1),y);
F(i,j)=f(i)*f(j)+f2(i)*f2(j);
S(i,j)=int(int(F(i,j),x,-h/(2*N),h/(2*N)),y,-h/(2*N),h/(2*N)); %积分
D1(1,i)=int(int(f(i),y,-h/(2*N),h/(2*N)),x,-h/(2*N),h/(2*N))/(h*h/(N*N));
D2(1,i)=int(int(f2(i),y,-h/(2*N),h/(2*N)),x,-h/(2*N),h/(2*N))/(h*h/(N*N));
end
end
G1=h*h/(N*N)*D1'*D1;
G2=h*h/(N*N)*D2'*D2;
G1=double(G1);
G2=double(G2);
S=double(S);
Gh=[G1 zeros(4);zeros(4) G2];
Sh=[S zeros(4);zeros(4) S];
E=eig(Gh,Sh);
Lambda=min(E(find(E~=0)));
计算程序是通过N的值来算相应的Lambda值,N=2,4,8然后画图,我写的程序它中间有个符号矩阵转数值矩阵,导致中图的G1,G2S矩阵含变量时用double()转换错误,上面是N=2的,求帮忙看看,谢谢。