I am trying to write a matrix where n=100, and the matrix's first and last number is 2 and all the number in the middle are 1.

To create a matrix where n=100 and the first and last numbers are 2, with all the numbers in between being 1, you can use the following steps:

1. Initialize an empty matrix with dimensions n x n. In this case, n = 100.

2. Set the value of the first element (0, 0) to 2.

3. Loop through each row of the matrix from the second row until the second-to-last row.

4. Inside this loop, set the value of the first element of the current row to 2 and the value of the last element of the current row to 2.

5. Loop through each element of the current row, starting from the second element and ending at the second-to-last element. Set each of these elements to 1.

6. After completing the loop, set the value of the last element (n-1, n-1) to 2.

Here is an example code in Python:

```python
n = 100

matrix = [[0 for _ in range(n)] for _ in range(n)] # Initialize the matrix

matrix[0][0] = 2 # Set the first element to 2

for i in range(1, n-1):
matrix[i][0] = 2 # Set the first element of each row to 2
matrix[i][-1] = 2 # Set the last element of each row to 2
for j in range(1, n-1):
matrix[i][j] = 1 # Set all the elements in between to 1

matrix[n-1][n-1] = 2 # Set the last element to 2

# Print the matrix
for row in matrix:
print(row)
```

By running this code, you will generate a matrix where n=100, with the first and last numbers being 2, and all the numbers in between being 1.