Solve MATLAB Matrix Equations & Find Eigenvalues, Vectors

In summary, the three people were discussing matlab commands to solve a system of equations. They all thought that the commands would be something like this: "A=[-1,3,-2,1;1,2,-4,-3;0,1,2,1;2,3,-1,-1]; b = [1;2;4;7]" However, when they tried to execute the commands, they found that they did not work. The first person tried to use A*B, but got an error message. The second person tried to use A'*B, but also got an error message. The third person tried to use A*B'*D, but also got an error message. They
  • #1
sara_87
763
0
Question 1:

Solve the system of equations

-w + 3x - 2y + z = 1
w + 2x - 4y - 3z = 2
x + 2y + z = 4
2w + 3x - y - z = 7

The attempt at a solution

To do this in matlab, this is what I will did:

>> A=[-1,3,-2,1;1,2,-4,-3;0,1,2,1;2,3,-1,-1]; b = [1;2;4;7]
>>x=inv(A)*b

Then MATLAB should give an answer with the solutions of w, x, y and z written in a separate line…no?

Question 2:

Find the eigenvalues and eigenvectors of the matrix

3, -1, 0, 0
-1, 5, -2, 0
0, -2, 6, -1
0, 0, -1, 2

The attempt at a solution

In MATLAB do I do this:

>>A=[3,-1,0,0;-1,5,-2,0;0,-2,6,-1;0,0,-1,2] ;
>>[V,D]=eig(A)

Then I should get an answer for V and D, and v is a matrix whose columns are the eigenvectors and D is the diagonal matrix, so we multiply the first column of V with the first diagonal of D etc… am I wrong?

Question 3:

Let

A=

-3, 4, 2, 0
1, -2, 0, 1
-4, 5, 0, 3
0, 1, -4, 2

Write the Matlab commands to construct the following matrix:

3, 0, 0, 0, -3, 1, -4, 0
0, 4, 0, 0, 4, -2, 5, 1
0, 0, 5, 0, 2, 0, 0, -4
0, 0, 0, 6, 0, 1, 3, 2
-3, 4, 2, 0, 5, 5, 5, 5
1, -2, 0, 1, 5, 5, 5, 5
-4, 5, 0, 3, 5, 5, 5, 5
0, 1, -4, 2, 5, 5, 5, 5

The attempt at a solution

In MATLAB should i do this:

>>A=[-3,4,2,0;1,-2,0,1;-4,5,0,3;0,1,-4,2]

Then to construct the other big matrix do I do this:

>> B=[diag(3:6),A’;A, fives(4,4)]

You’ve probably all figured that I don’t have access to MATLAB just now, so I would be grateful if someone who has access to MATLAB could just copy and paste the commands into see if it works.

Also between each question do I write clear all to clear everything before I start the question?
 
Last edited:
Physics news on Phys.org
  • #2
For question 2, you don't have to do anything after eig.

D is a diagonal matrix of eigenvalues - just read them off the diagonal, and V is the corresponding matrix of eigenvectors - just take each column separately.

(You also have the relationship A*V=V*D - this is what you may be thinking when you want to multiply...?)

Qu 3 is right but for, there is no such thing as fives: use 5*ones(4,4).

Qu 1 looks good too.
 
Last edited:
  • #3
ok thanx
do you know if i did Question 3 right coz i have a feeling it is wrong?
 
  • #4
See edit above for Qu3.
 
  • #5
ok thanks i really appreciate your help!

and you didn't have to say 'there is no such thing' just correct me lol
 
  • #6
sara_87 said:
and you didn't have to say 'there is no such thing' just correct me lol
That's my new found Dutch abruptness invading my English politeness :tongue:
 

What is a matrix equation in MATLAB?

A matrix equation in MATLAB is an expression that involves matrices and vectors, where the goal is to solve for the unknown matrix or vector. It is represented as Ax = b, where A is the coefficient matrix, x is the unknown vector, and b is the constant vector.

How do I solve a matrix equation in MATLAB?

To solve a matrix equation in MATLAB, you can use the backslash operator (\) or the inv function. The backslash operator is more efficient and should be used whenever possible. For example, to solve Ax = b, you can use the command x = A\b.

What are eigenvalues and eigenvectors in MATLAB?

Eigenvalues and eigenvectors in MATLAB are the values and corresponding vectors that satisfy the equation Av = λv, where A is a square matrix, v is the eigenvector, and λ is the eigenvalue. They are used to understand the behavior of a matrix and can be found using the eig function.

How do I find eigenvalues and eigenvectors in MATLAB?

To find eigenvalues and eigenvectors in MATLAB, you can use the eig function. This function returns a diagonal matrix of eigenvalues and a matrix of corresponding eigenvectors. Alternatively, you can use the eigvals and eigvecs functions to get just the eigenvalues or eigenvectors, respectively.

What is the significance of eigenvalues and eigenvectors in MATLAB?

Eigenvalues and eigenvectors in MATLAB are important for understanding the behavior of a matrix. They can be used to determine if a matrix is invertible, to find the direction of maximum change in a system, and to perform transformations on vectors. They are also used in many applications, such as data analysis and machine learning.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
487
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top