In Matlab I'm trying to create a 3^(n-1) by n matrix containing in each row a scenario of a trinomial tree. i.e. in total all the rows together contain all possible paths that can be followed in the tree. At each point in the tree the path goes either up, stay the same or go down. I want to denote this in the matrix with 1, 0 or -1 respectively. An example for n = 3 would be:
[0,-1,-1;
0,-1,0;
0,-1,1;
0,0,-1;
0,0,0;
0,0,1;
0,1,-1;
0,1,0;
0,1,1]
I want to generalize this for n steps.