We present primary and secondary generators for the algebra of polynomial invariants of the direct product of two copies of the special linear group Sl3 acting naturally on triples of 3 × 3 matrices over a field of characteristic zero. We handle also the analogous problem for triples and quadruples of 2 × 2 matrices.