www.gusucode.com > pde 案例源码 matlab代码程序 > pde/EigenvaluesLShapedMembraneCommandLineExample.m
%% Eigenvalues for the L-Shaped Membrane Using Command-Line Functions % This example shows how to calculate eigenvalues and eigenvectors using % command-line functions. The geometry of the L-shaped membrane is % described in the file |lshapeg|.Create a model and include this geometry. model = createpde(); geometryFromEdges(model,@lshapeg); %% % Set zero Dirichlet boundary conditions on all edges. applyBoundaryCondition(model,'dirichlet','Edge',1:model.Geometry.NumEdges,'u',0); %% % Recall the general eigenvalue PDE problem description: % % $$ -\nabla\cdot(c\nabla u) + au = \lambda d u.$$ % % Create coefficients for the problem % % $$ -\nabla\cdot(\nabla u) = \lambda u.$$ % % This has coefficients |d| = 1 and |c| = 1, and all other coefficients % equal to zero. specifyCoefficients(model,'m',0,'d',1,'c',1,'a',0,'f',0); %% % Set the interval |[0,100]| as the region for the eigenvalues in the % solution. r = [0,100]; %% % Create a mesh and solve the problem. generateMesh(model,'Hmax',0.05); results = solvepdeeig(model,r); %% % See how many solutions you obtained. length(results.Eigenvalues) %% % There are 19 eigenvalues smaller than 100. Plot the first eigenmode and % compare it to the MATLAB(R) |membrane| function. u = results.Eigenvectors; pdeplot(model,'XYData',u(:,1),'ZData',u(:,1)); figure membrane(1,20,9,9) %% % Eigenvectors can be multiplied by any scalar and remain eigenvectors. % This explains the difference in scale that you see. % % |membrane| can produce the first 12 eigenfunctions for the L-shaped % membrane. Compare also the 12th eigenmodes. Multiply the PDE % solution by -1 to have the plots look similar instead of inverted. figure pdeplot(model,'XYData',-u(:,12),'ZData',-u(:,12)); figure membrane(12,20,9,9) %% % Actually, the eigenvalues of the square can be computed exactly. They are % % $$ \left (m^2 + n^2\right )\pi^2,$$ % % e.g., the double eigenvalue $\lambda_{18}$ and $\lambda_{19}$ is % $10\pi^2$, which is pretty close to 100.