Use the diag command to find matrix and find dominant eigenvalues

Consider the following vectors, which you can copy and paste directly into Matlab.
x = [2 1 2 6 6 5 5 5 5 5 4 6];
y = [6 5 6 2 5 2 1 2 2 6 5];
Use the vectors x and y to create the following matrix.
2 6 0 0 0 0 0 0 0 0 0 0
6 1 5 0 0 0 0 0 0 0 0 0
0 5 2 6 0 0 0 0 0 0 0 0
0 0 6 6 2 0 0 0 0 0 0 0
0 0 0 2 6 5 0 0 0 0 0 0
0 0 0 0 5 5 2 0 0 0 0 0
0 0 0 0 0 2 5 1 0 0 0 0
0 0 0 0 0 0 1 5 2 0 0 0
0 0 0 0 0 0 0 2 5 2 0 0
0 0 0 0 0 0 0 0 2 5 6 0
0 0 0 0 0 0 0 0 0 6 4 5
0 0 0 0 0 0 0 0 0 0 5 6
Such a matrix is called a tri-diagonal matrix. Hint: Use the diag command three times, and then add the resulting matrices.
To check that you have correctly created the matrix A, verify that det(A) = -4.2749e+07.
Find the dominant eigenvalue of A.

 Risposta accettata

Rather than copying and pasting your homework assignment into the above, why not include an attempt at solving it? The question gives a hint as use the diag command three times, and then add the resulting matrices. Look at an example from diag
v = [2 1 -1 -2 -5];
diag(v)
ans =
2 0 0 0 0
0 1 0 0 0
0 0 -1 0 0
0 0 0 -2 0
0 0 0 0 -5
Which of your two vectors would you use (in the above) in place of v? Now how would you copy the other vector above or below the main diagonal? Look at the documentation for diag and the answer will be apparent.

Più risposte (1)

Consider the following vector x, which you can copy and paste directly into Matlab.
x = [2 5 3 3 2 2 6 3 3 3 5 4 5 2 4 4 3 3 2 3 1 6 2 4 3]'
Use the reshape command to reshape the vector x into a square matrix, and then find the determinant of the resulting matrix.

Categorie

Scopri di più su Linear Algebra in Centro assistenza e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by