Hello,
I'm trying to fill an array by for. The idea is to generate the diagonal of the array by a progression, and then replicate each element at (i,i) to the remnants rows below it . The part that makes the diagonal works just fine (from the first for to the end of the second for), but the part that replicate the diagonal value (the If line) to the lower part of the array messed up at column n-2 (it's always the n-2 column that fails). At this point I'm at lost of what is failing.
Here is the code:
Clear["Global`*"]
n=4;
V=Array[v,n+1,0];
v[0]=0;
A=Array[a, {n, n}];
For[i=1,i<=n,i++,
a[i,i]=V[[i+1]];
For[j=1, j<=i,j++,
a[i,i]=Append[{a[i, i]}, j*p+V[[1+i-j]]];
];
If[i<n, A[[i + 1 ;; n, i]] = a[i, i]];
]
MatrixForm[A]
Any feedback is welcome. Thanks.