In reply to Arne Cordes.

I don't know what you mean by "the first matrix" and "the second [matrix]". If you are trying to perform some sort of animation (like blinking lights), then set
ID = j(nrow(M), 1, 1); /* for first tree */
create Tree var {"Row" "Col" "M" "ID"}; append;
then create the new M and submit
ID = j(nrow(M), 1, 2); /* for second tree */
create Tree var {"Row" "Col" "M" "ID"}; append;
etc. You can do this in a loop to save typing.