how to make the numbers on the matrix with alternative sign?
1 view (last 30 days)
I want to create a matrix that the main diagonal of K are alternatively 2 and -2’s, the sub- and sup-diagonal of K alternatively 1 and -1’s, and everywhere else 0. The size of K is 2n by 2n.
Here is what I got so far.
[rows, columns] = size(z)
z(1:2*rows+2:end) = -z(1:2*rows+2:end)