Question: Writing a diagonal Matrix

Hi. I have nodes:=7

How do i write a matrix with my first set of nodes = -1 and a second set as 1, in a diagonal form? Sort of like a identity matrix but not quite.

What I did was to write J:=Matrix([[-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1]])    ####my vector will have 2 times the number of my nodes.

Then DiagonalMatrix(J)

But I then want to change my number of nodes. Could you please advice if there's a smarter way to do this please?

Many thanks.

 

Please Wait...