Solve Matlab Eigenvectors Homework

In summary, the conversation involved a discussion about using the function [V,D]=eig(A) in MATLAB to find eigenvectors and eigenvalues. The attempt at a solution involved using .* instead of * for multiplication, which resulted in an incorrect answer. The correct solution is to use * for matrix multiplication, and the resulting matrix is very close to the original matrix A.
  • #1
jdawg
367
2

Homework Statement


I think this problem is supposed to be pretty simple, but I have almost no knowledge of how to use matlab. I was told to use this function: [V,D]=eig(A) to give me the eigenvectors (columns of matrix V) and the diagonal matrix with eigenvales in the diagonal ( matrix D). I also need to check the matrix with A=VDV-1.

Homework Equations

The Attempt at a Solution


I don't feel like this is right, but this is what I tried:
Here is what I typed in the script:

%1
A=[1 -3 3 3; -1 4 -3 -3; -2 0 1 1; 1 0 0 0]
[V,D]=eig(A)
V.*D.*inv(V)

And here is what came out:

A =

1 -3 3 3
-1 4 -3 -3
-2 0 1 1
1 0 0 0V =

-0.0000 0.0000 0.0000 0.5607
-0.0000 -0.7071 0.7071 -0.7476
0.7071 -0.7071 0.7071 -0.3271
-0.7071 0.0000 0.0000 0.1402D =

0.0000 0 0 0
0 1.0000 0 0
0 0 1.0000 0
0 0 0 4.0000ans =

1.0e+07 *

-0.0000 0 0 0
0 -1.0712 0 0
0 0 -1.0712 0
0 0 0 0.0000
[/B]
 
Last edited:
Physics news on Phys.org
  • #2
jdawg said:
%1
A=[1 -3 3 3; -1 4 -3 -3; -2 0 1 1; 1 0 0 0]
[V,D]=eig(A)
V.*D.*inv(V)

You're close. The key here is that .* does elementwise multiplication (corresponding elements are multiplied, the result is the same size as the inputs), whereas * does matrix multiplication (you know, where an NxM matrix multiplied by an MxP matrix results in an NxP matrix).

You want to use * instead of .*, and when you do that you'll get a much better answer for the check:

Code:
V*D*inv(V)

ans =

    1.0000   -3.0000    3.0000    3.0000
   -1.0000    4.0000   -3.0000   -3.0000
   -2.0000   -0.0000    1.0000    1.0000
    1.0000    0.0000   -0.0000   -0.0000

Since the condition number of V is rather large, calculating the inverse introduces some error, so the above matrix isn't exactly equal to A, but it's close.

Code:
A - V*D*inv(V)

ans =

   1.0e-07 *

   -0.1285   -0.1285    0.1285    0.1285
    0.1286    0.1656   -0.1386   -0.1551
   -0.0052    0.0250    0.0221    0.0056
   -0.0072   -0.0072    0.0072    0.0072
 
  • #3
Perfect! Thanks so much!
 

1. How do I calculate eigenvectors in Matlab?

To calculate eigenvectors in Matlab, you can use the eig function. This function takes in a square matrix as the input and returns the eigenvectors and eigenvalues as outputs. For example, if A is a matrix, then [V,D] = eig(A) will give you the eigenvectors in the matrix V.

2. What is the significance of eigenvectors and eigenvalues?

Eigenvectors and eigenvalues are important concepts in linear algebra that help us understand the behavior of a matrix. Eigenvectors are special vectors that when multiplied by a matrix, result in a scalar multiple of the original vector. Eigenvalues represent the scaling factor for the eigenvectors. They are used in various applications such as image processing, data compression, and machine learning.

3. How do I find the dominant eigenvector in Matlab?

The dominant eigenvector is the eigenvector corresponding to the largest eigenvalue of a matrix. To find the dominant eigenvector in Matlab, you can use the eigs function. This function takes in a square matrix and the number of eigenvalues you want to compute as inputs and returns the eigenvalues and eigenvectors in descending order. The first column of the eigenvector matrix will be the dominant eigenvector.

4. Can I compute eigenvectors for non-square matrices in Matlab?

No, eigenvectors can only be computed for square matrices in Matlab. If you have a non-square matrix, you can first use the svd function to decompose it into its singular values and vectors, and then use the eig function to find the eigenvectors.

5. How can I use eigenvectors to diagonalize a matrix in Matlab?

To diagonalize a matrix in Matlab using eigenvectors, you can use the diag function. This function takes in a vector of eigenvalues and returns a diagonal matrix with the eigenvalues on the main diagonal. You can then use the inverse of the eigenvector matrix to transform the original matrix into a diagonal matrix.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
18
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
823
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top