# A large matrix in matlab

## Homework Statement

I need to create a 121*121 matrix in matlab. Forty of the rows have to contain the sequence 0 1 0 0 1 -4 1 0 0 1. and the rest of the rows will have 0's and "one 1" per row. The sequence has to be pushed one step to the right from row 1 to 121, the result should be a matrix with only -4's and 1's on the diaogonal.

The first 12 rows will have the form:
1 0 0 0 0 0 0 0 0 0 0........
0 1 0 0 0 0 0 0 0 0 0.......
0 0 1 0 0 0 0 0 0 0 0........

Then the rows with the -4's appear 9 times being separated by only two rows of type 1 and 0.
example:
1 0 0 0 0 0 0 0 0 0 0........
0 1 0 0 0 0 0 0 0 0 0.......
0 0 1 0 0 0 0 0 0 0 0........
11 rows
then
9 rows of
0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0 0 0 0........
0 0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0 0 ......
0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 ......
after the 9 rows then two of only 1 and 0 again. and it continues like that for 110 rows down, with the remaining being like the twelve first with only 1 and zeros.

phew! Hope this is possible to understand. I have very little experience with programing, so I find this really hard.

## The Attempt at a Solution

Mons

You may want to investigate the use of the functions "diag" and "eye" . If you could clarify that second matrix you've posted (since it looks the same as the one above it), I could give a little bit more direction.

hi. thank you for helping me.

The pattern is as follows

1 0 0 0 0 0 0 0 0 0 0........
0 1 0 0 0 0 0 0 0 0 0.......
0 0 1 0 0 0 0 0 0 0 0........
0 0 0 1 0 0 0 0 0 0 0 0 0 0........
0 0 0 0 1 0 0 0 0 0 0 0 0 0.......
0 0 0 0 0 1 0 0 0 0 0 0 0 0........
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0........
0 0 0 0 0 0 0 1 0 0 0 0.......
0 0 0 0 0 0 0 0 1 0 0 0....
0 0 0 0 0 0 0 0 0 1 0 0 0........
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0........
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0.......
0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0 0 0 0........
0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0 0 ......
0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 ......
0 0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0 0 0 0........
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0 0 ......
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 ......
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0 0 0 0........
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 0 0 0 0 ......
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 -4 1 0 0 1 0 0 0 ......
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0........
then 9 rows with -4 in them, then two with only 1 and 0 again......
this continues until row 110, and the 11 are with only 1 and 0.

hope this is possible to understand=).

the diagonal should only consist of 4s and 1s.