My eig function worked once and then broke

3 views (last 30 days)
Hello everyone,
I am currently trying to solve a vibrant system, and I need its eigenvalues and eigenvectors. I so used the eig() function, as following:
[EigVec, EigVal] = eig(K\M, 'vector') % K the stiffness matrix, M the mass matrix
I tried it once and got the exact right results. I modified some values in the mass matrix and now this line isn't working anymore. I get the following error:
Error using sym/eig
Too many input arguments.
Error in Homework2 (line 347)
[EigVect, EigVal] = eig(K\M, 'vector');
I also tried:
[EigVec, EigVal] = eig(K\M)
And now I get absurd values.
Any ideas of what happened?
  1 Comment
Christine Tobler
Christine Tobler on 20 Apr 2022
It sounds like originally your matrices didn't contain symbolic variables, so the eig command accepted the 'vector' option (eig for symbolic variables doesn't accept any option strings). Then you changed M so that it's now a symbolic variable - and those have quite different behavior, since it's not numerical calculation anymore but symbolic.
Can't really tell more since I don't know what you mean by absurd values, or what you expect in terms of symbolic calculation (for example, is M a specific number just in stored symbolically, or does it contain symbolic unknowns)?
We really need reproduction steps of what K and M are, and what you're hoping to compute, to help any more.

Sign in to comment.

Accepted Answer

Bruno Luong
Bruno Luong on 20 Apr 2022
Don't use symbolic variable to build your matrices.
  2 Comments
Benjamin KOENIG
Benjamin KOENIG on 20 Apr 2022
I banned all symbolic variables from my code, but it doesn't look like it changed anything. I still have the error and absurd values.
Bruno Luong
Bruno Luong on 20 Apr 2022
Edited: Bruno Luong on 20 Apr 2022
"Error using sym/eig"
implies you have symbolic variable.
If
eig(K\M)
returns "absurd" result perhaps your matrices input is not correct ("I modified some values in the mass matrix" but what?) . But you don't tell us what ther are and why it is absurd. The only absurd thing to me is that you expect useful help from so little information.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!