How to Create a Specific 121x121 Matrix in MATLAB?

  • Thread starter Thread starter monsmatglad
  • Start date Start date
  • Tags Tags
    Matlab Matrix
AI Thread Summary
To create a 121x121 matrix in MATLAB, the first 12 rows should contain a sequence of 1s and 0s, followed by a repeating pattern of 9 rows that include the sequence "0 1 0 0 1 -4 1 0 0 1" interspersed with two rows of only 1s and 0s. The sequence must be shifted one step to the right for each subsequent row, ensuring that the diagonal of the matrix consists solely of -4s and 1s. Functions like "diag" and "eye" may be useful for constructing this matrix. The overall structure requires careful attention to the placement of the sequences to achieve the desired matrix configuration.
monsmatglad
Messages
75
Reaction score
0

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.

Homework Equations


please ask for expanation if you don't understand.

The Attempt at a Solution



Mons
 
Physics news on Phys.org
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.
 
Thread 'Have I solved this structural engineering equation correctly?'
Hi all, I have a structural engineering book from 1979. I am trying to follow it as best as I can. I have come to a formula that calculates the rotations in radians at the rigid joint that requires an iterative procedure. This equation comes in the form of: $$ x_i = \frac {Q_ih_i + Q_{i+1}h_{i+1}}{4K} + \frac {C}{K}x_{i-1} + \frac {C}{K}x_{i+1} $$ Where: ## Q ## is the horizontal storey shear ## h ## is the storey height ## K = (6G_i + C_i + C_{i+1}) ## ## G = \frac {I_g}{h} ## ## C...
Back
Top