How to Create a Specific 121x121 Matrix in MATLAB?

  • Thread starter Thread starter monsmatglad
  • Start date Start date
  • Tags Tags
    Matlab Matrix
Click For Summary

Discussion Overview

The discussion revolves around creating a specific 121x121 matrix in MATLAB, focusing on the arrangement of sequences of 1's, 0's, and -4's across the matrix. The participants explore the requirements for the matrix structure, including the placement of specific patterns and the overall diagonal composition.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes the need for the first 12 rows to contain a sequence of 1's and 0's, followed by a pattern that includes -4's and 1's, with specific spacing between these sequences.
  • Another participant suggests investigating MATLAB functions such as "diag" and "eye" to assist in creating the matrix.
  • A participant provides a detailed breakdown of the desired pattern, reiterating the arrangement of 1's and 0's, and the placement of -4's in the matrix.
  • There is a clarification that the diagonal of the matrix should consist only of 1's and -4's, which may imply a need for further refinement of the proposed structure.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the exact structure of the matrix, and there are competing interpretations of how the sequences should be arranged, particularly regarding the diagonal elements.

Contextual Notes

The discussion includes assumptions about the matrix structure that may not be fully articulated, such as the specific placement of -4's and the overall diagonal composition. There are also unresolved details regarding the implementation in MATLAB.

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.
 

Similar threads

Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K