Building global stiffness matrix from element stiffness matrices is
something that should be explained in number of textbooks. Maybe your
textbook does not show this? There are number of places on the net that show
how to do this as well.
google "assembly of global stiffness matrix" , I get 423,000 hits.
This site below seems to have a nice demo how to do this
http://www.u-aizu.ac.jp/~niki/javaappl/jassem/jassem.html
For a class I took, I wrote a small report on FEM, and at the end of it I
have an example for a 2D assembly of global stiffness matrix, see end of
this:
http://www.12000.org/my_courses/UCI_COURSES/CREDIT_COURSES/spring_2006/spring_MAE_207/other_class_documents/Nasser_Abbasi/lecture_notes_nov_27_2006/HTML/report_fixed.htm
If you are looking for a function as part of standard matlab to do this, I
am not sure there is one, but may be in some toolbox, You can Google around
and search.
Nasser