Calculating Eigenvalues w/ MATLAB: Defining Variables k,α,β,γ

In summary, variables in MATLAB can be defined using the assignment operator or the "input" function. Eigenvalues in MATLAB represent the scaling factor of eigenvectors when a linear transformation is applied. To calculate eigenvalues, the "eig" function can be used with a square matrix as an input. In the context of calculating eigenvalues, k, α, β, and γ are often used to represent the coefficients of a characteristic polynomial. However, other variables can also be used as long as they are not already defined in the workspace. It is important to choose meaningful variable names to avoid confusion and errors in code.
  • #1
quansnow
5
0
I use the command eig(A) to calculate the eigenvalues of the matrix A, in which k,α,β,γ are variables,

A=[-0.5*k -i*α 0;-i*α -0.5*γ -i*β;0 i*β -0.5k];
eig(A)

but the MATLAB shows "Undefined function or variable 'k'."
I don't know how to define the variables k,α,β,γ.
Can anyone tell me how to do it? Thanks!
 
Physics news on Phys.org
  • #3
It works. Thanks a lot!
 

1. How do I define variables in MATLAB?

In MATLAB, variables can be defined using the assignment operator "=" followed by the desired value or expression. For example, to define a variable "k" with a value of 5, you would type "k = 5" in the command window. Variables can also be defined using the "input" function, which allows the user to input a value during runtime.

2. What are eigenvalues in MATLAB?

Eigenvalues in MATLAB are a set of values that represent the scaling factor of the eigenvector when a linear transformation is applied to it. In other words, they represent the factors by which the eigenvectors are stretched or compressed when a transformation is applied. Eigenvalues are often used in linear algebra and are useful for solving systems of linear equations.

3. How do I calculate eigenvalues in MATLAB?

To calculate eigenvalues in MATLAB, you can use the "eig" function. This function takes in a matrix as an input and returns a vector of eigenvalues. For example, if you have a 3x3 matrix A, you can calculate its eigenvalues by typing "eig(A)" in the command window. It is important to note that the matrix must be square in order for eigenvalues to be calculated.

4. What do the variables k, α, β, and γ represent in calculating eigenvalues?

In the context of calculating eigenvalues, k, α, β, and γ are often used to represent the coefficients of a characteristic polynomial. The characteristic polynomial is a polynomial equation that is used to find the eigenvalues of a matrix. The variable k represents the degree of the polynomial, while α, β, and γ represent the coefficients of the polynomial.

5. Can I use variables other than k, α, β, and γ to calculate eigenvalues?

Yes, you can use variables other than k, α, β, and γ to calculate eigenvalues in MATLAB. In fact, you can use any valid variable name as long as it is not already defined in your workspace. It is important to use variable names that are meaningful and easy to understand in order to avoid confusion and errors in your code.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
851
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
987
Replies
18
Views
995
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • Advanced Physics Homework Help
Replies
3
Views
1K
  • Special and General Relativity
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
44
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top