www.gusucode.com > pde 案例源码 matlab代码程序 > pde/EigenvaluesAndEigenvectorsUsingFiniteElementMatricesExample.m
%% Eigenvalues and Eigenvectors Using Finite Element Matrices % Import a simple 3-D geometry and find eigenvalues and eigenvectors from % the associated finite element matrices. %% % Create a model and import the |BracketWithHole.stl| geometry. model = createpde(); importGeometry(model,'BracketWithHole.stl'); figure pdegplot(model,'FaceLabels','on') view(30,30) title('Bracket with Face Labels') figure pdegplot(model,'FaceLabels','on') view(-134,-32) title('Bracket with Face Labels, Rear View') %% % Set coefficients |c = 1|, |a = 0|, and |d = 1|. Collect eigenvalues that % are less than 100. c = 1; a = 0; d = 1; r = [-Inf 100]; %% % Generate a mesh for the model. generateMesh(model); %% % Create the associated finite element matrices. [Kc,~,B,~] = assempde(model,c,a,0); [~,M,~] = assema(model,0,d,0); %% % Solve the eigenvalue problem. [v,l] = pdeeig(Kc,B,M,r); %% % Look at the first two eigenvalues. l([1,2]) %% % Plot the solution corresponding to eigenvalue 2. pdeplot3D(model,'ColorMapData',v(:,2))