I wanted to create a list of matrices from the following rules:
i- All matrices of the list have diagonal equal to zero.
ii- The first matrix have 2x2 dimension, m2={{0,1},{0,0}}
iii- Draw RandomInteger[{1,2}]
; 2 is dimension of the matrix start
iv- The next matrix (m3) have 3x3 dimensions and the submatrix have same elements of the matrix write in step ii; the other elements are obtained by RandomNumber (step iii) and elments of the step (ii): The elements of the last Column are: m3[[1,3]]=m2[[1,2]], m3[[2,3]]=m2[[2,2]]
. The elements of the last line are m3[[3,1]]=m3[[1,1]], m3[[3,2]]=m3[[1,2]]
.
v- The next matrix have dimension 4x4; repeat the same elements of the step iv and draw a new RandomInteger[{1,3}] (3 is the dimension of the matrix in step iv). The other elements are obtnained from the matrix m3 and RandomInteger.
For instance: look the figure below
. I thought in the code below, but is not working
nmax = 15 ;(*number of matrices*)
m2 = {{0, 1}, {0, 0}} ;(*The matrix begin - start matrix*)
d = 2(*dimension of the matrix begin*);
q = Table[
RandomInteger[{1, i}], {i, 2, nmax - 1}](*List of Random Integer*)
f[i_, j_] :=
If[i <= d && j <= d, m2[[i, j]],
If[j == i, 0,
If[j > i, With[{s = q[[j - d]]}, mat[[i, s]]],
With[{p = q[[i - d]]}, mat[[p, j]]]]]](*Rules*)
mat = Array[f, {nmax, nmax}](*write in variable mat the matrix m2*)
c = Table[
mat[[;; i, ;; i]], {i, d,
Length@mat}];(*generate the list of matrix*)
Table[MatrixForm[c[[i]]], {i,
nmax - 1}](*Matrix Form of the list matrix*)
Please, somebody help me?