# Eigenvalues and Eigenmodes of L-Shaped Membrane

This example shows how to calculate eigenvalues and eigenvectors. The eigenvalue problem is $-\Delta u=\lambda u$. This example computes all eigenmodes with eigenvalues smaller than 100.

Create a model and include this geometry. The geometry of the L-shaped membrane is described in the file `lshapeg`.

```model = createpde(); geometryFromEdges(model,@lshapeg);```

Set zero Dirichlet boundary conditions on all edges.

```applyBoundaryCondition(model,"dirichlet", ... "Edge",1:model.Geometry.NumEdges, ... "u",0);```

Specify the coefficients for the problem: `d` = 1 and `c` = 1. All other coefficients are 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);```
``` Basis= 10, Time= 0.12, New conv eig= 0 Basis= 11, Time= 0.16, New conv eig= 0 Basis= 12, Time= 0.17, New conv eig= 0 Basis= 13, Time= 0.18, New conv eig= 0 Basis= 14, Time= 0.19, New conv eig= 0 Basis= 15, Time= 0.21, New conv eig= 0 Basis= 16, Time= 0.21, New conv eig= 0 Basis= 17, Time= 0.22, New conv eig= 0 Basis= 18, Time= 0.22, New conv eig= 1 Basis= 19, Time= 0.23, New conv eig= 1 Basis= 20, Time= 0.23, New conv eig= 1 Basis= 21, Time= 0.24, New conv eig= 2 Basis= 22, Time= 0.26, New conv eig= 3 Basis= 23, Time= 0.27, New conv eig= 3 Basis= 24, Time= 0.28, New conv eig= 3 Basis= 25, Time= 0.30, New conv eig= 3 Basis= 26, Time= 0.31, New conv eig= 3 Basis= 27, Time= 0.32, New conv eig= 3 Basis= 28, Time= 0.32, New conv eig= 4 Basis= 29, Time= 0.33, New conv eig= 4 Basis= 30, Time= 0.33, New conv eig= 4 Basis= 31, Time= 0.34, New conv eig= 5 Basis= 32, Time= 0.34, New conv eig= 5 Basis= 33, Time= 0.35, New conv eig= 5 Basis= 34, Time= 0.36, New conv eig= 5 Basis= 35, Time= 0.36, New conv eig= 6 Basis= 36, Time= 0.63, New conv eig= 6 Basis= 37, Time= 0.66, New conv eig= 6 Basis= 38, Time= 0.67, New conv eig= 7 Basis= 39, Time= 0.70, New conv eig= 7 Basis= 40, Time= 0.71, New conv eig= 7 Basis= 41, Time= 0.72, New conv eig= 7 Basis= 42, Time= 0.73, New conv eig= 7 Basis= 43, Time= 0.75, New conv eig= 8 Basis= 44, Time= 0.77, New conv eig= 8 Basis= 45, Time= 0.78, New conv eig= 9 Basis= 46, Time= 0.79, New conv eig= 11 Basis= 47, Time= 0.81, New conv eig= 11 Basis= 48, Time= 0.83, New conv eig= 11 Basis= 49, Time= 0.85, New conv eig= 11 Basis= 50, Time= 1.03, New conv eig= 13 Basis= 51, Time= 1.08, New conv eig= 13 Basis= 52, Time= 1.11, New conv eig= 14 Basis= 53, Time= 1.13, New conv eig= 14 Basis= 54, Time= 1.16, New conv eig= 14 Basis= 55, Time= 1.18, New conv eig= 14 Basis= 56, Time= 1.19, New conv eig= 14 Basis= 57, Time= 1.21, New conv eig= 14 Basis= 58, Time= 1.22, New conv eig= 14 Basis= 59, Time= 1.23, New conv eig= 15 Basis= 60, Time= 1.24, New conv eig= 15 Basis= 61, Time= 1.40, New conv eig= 15 Basis= 62, Time= 1.44, New conv eig= 16 Basis= 63, Time= 1.46, New conv eig= 16 Basis= 64, Time= 1.48, New conv eig= 16 Basis= 65, Time= 1.50, New conv eig= 17 Basis= 66, Time= 1.53, New conv eig= 17 Basis= 67, Time= 1.54, New conv eig= 18 Basis= 68, Time= 1.56, New conv eig= 18 Basis= 69, Time= 1.58, New conv eig= 18 Basis= 70, Time= 1.60, New conv eig= 19 Basis= 71, Time= 1.62, New conv eig= 20 Basis= 72, Time= 1.63, New conv eig= 21 Basis= 73, Time= 1.65, New conv eig= 21 Basis= 74, Time= 1.65, New conv eig= 22 End of sweep: Basis= 74, Time= 1.65, New conv eig= 22 Basis= 32, Time= 1.67, New conv eig= 0 Basis= 33, Time= 1.69, New conv eig= 0 Basis= 34, Time= 1.70, New conv eig= 0 Basis= 35, Time= 1.71, New conv eig= 0 Basis= 36, Time= 1.72, New conv eig= 0 Basis= 37, Time= 1.73, New conv eig= 0 Basis= 38, Time= 1.74, New conv eig= 0 Basis= 39, Time= 1.74, New conv eig= 0 Basis= 40, Time= 1.74, New conv eig= 0 Basis= 41, Time= 1.75, New conv eig= 0 Basis= 42, Time= 1.75, New conv eig= 0 End of sweep: Basis= 42, Time= 1.75, New conv eig= 0 ```

There are 19 eigenvalues smaller than 100.

`length(results.Eigenvalues)`
```ans = 19 ```

Plot the first eigenmode and compare it to the MATLAB's `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 the 12th eigenmodes.

```figure pdeplot(model,"XYData",u(:,12),"ZData",u(:,12));```

```figure membrane(12,20,9,9)```