Error when creating Matrix from a FOR-LOOP