里兹法的MATLAB实现 振动力学

function [D,C]=RitzTorsionD(a,b,n)% This function calculates the torsional rigidity of rectangular s

[D,C]=RitzTorsionD(a,b,n) function %Thisfunctioncalculatesthetorsionalrigidityofrectangularsection %basedonRitzmethod,inwhichthetrialfunctionis %(x^2-a^2)*(y^2-b^2)*(C1+C2*x^2*y^2+C3*x^4*y^4+C4*x^6*y^6+...) %Usage: %[C,D]=RitzTorsion(a,b,n) %Input: %a------widthofthesection %b------heightofthesection %n------thenumberofthetrialfunctions %Output: %D------thetorsionalrigidity %C------thecoefficientsofthetrialfunctions % %------------------------------------------------------------- %--------------------------------------------------------------- nargin<3 if a=1; b=1; n=4; end syms xy C=zeros(n,1); D=0; F0=(x^2-a^2)*(y^2-b^2); F=sym(zeros(n,1)); i=1:n for j=2*(i-1); F(i)=F0*x^j*y^j; end Fx=diff(F,x); Fy=diff(F,y); A=zeros(n,n); B=zeros(n,1); i=1:n for j=1:n for A(i,j)=eval(2*int(int(Fx(i)*Fx(j)+Fy(i)*Fy(j),x,-a,a),y,-b,b)); end B(i)=eval(4*int(int(F(i),x,-a,a),y,-b,b)); end C=A\B; D=sum(C.*B/2); return

腾讯文库里兹法的MATLAB实现