We give an efficient solution to the following problem: Given X 1 , . . . X d and Y some n by n matrices can we determine if Y is in the unital algebra generated by X 1 , . . . , X d as a subalgebra of all n by n matrices? The solution also gives an easy method for computing the dimension of this algebra.2010 Mathematics Subject Classification. Primary 16S50, 15A30 Secondary 47A57 . Key words and phrases. calculation of matrix algebras from generators, dimension of matrix algebras, bases for matrix algebras.