# Assemble P2 finite elements - Matlab or references

I would like to implement P2 (or even P3...) finite elements in Matlab. I need to be able to control the construction of the rigidity and mass matrices ($\int \nabla \varphi_i\cdot \nabla \varphi_j$ and $\int \varphi_i \varphi_j$) (since I want to tackle some precision computation problems afterwards, and maybe go beyond machine precision using Advanpix...)

If there are already some good Matlab codes which do this, please point me to them. If not, are there any good references from where I could learn to do this properly?

I would like to avoid doing all the computations by hand if possible since I'm sure someone else has done them before :) ... (find the right basis functions, compute explicitly all integrals of products of neighbor basis functions, etc...)