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

AI Thread Summary
To calculate the eigenvalues of a matrix with symbolic variables in MATLAB, the command eig(A) requires the variables to be defined first. The error "Undefined function or variable 'k'" indicates that the variables k, α, β, and γ are not recognized. To define these variables, the 'syms' function can be used, which is a shortcut for the 'sym()' function in MATLAB. This allows for the creation of symbolic variables, enabling the calculation of eigenvalues for the matrix A. The provided link to MATLAB's documentation on symbolic variables confirms this approach.
quansnow
Messages
3
Reaction score
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
It works. Thanks a lot!
 

Similar threads

Replies
2
Views
2K
Replies
2
Views
3K
Replies
2
Views
2K
Replies
7
Views
2K
Replies
44
Views
6K
Replies
1
Views
5K
Back
Top