I am working in MATLAB and want to convert the following snippet into WL code to run on Mathematica.
u(j,j) = number1(j); //Some function of j that calculates the number
u(j,j+1) = number2(j);
u(j,j-1) = numer2(j);
The matrix u was not previously initialized. Basically I want to create a matrix which I can continuously append numbers to.
I know how to do something similar with vectors, namely,
u = {initialValue};
While[..., AppendTo[u, someNumber[i]], ...]
Hpw can I extend this to matrices for arbitrary $j$?
SparseArray[{Band[{1, 1}] -> number1, Band[{2, 1}] -> number2, Band[{1, 2}] -> number2 }, {5, 5}] // MatrixForm
$\endgroup$