# Eig Argument Command Error

14 visualizaciones (últimos 30 días)
Daniel Murphy el 30 de Abr. de 2022
Editada: Andreas Apostolatos el 30 de Abr. de 2022
clear; close all; clc
m = 25;
EI = 100;
L = 1;
Ke = EI/L^3*[12 6*L -12 6*L
6*L 4*L^2 -6*L 2*L^2
-12 -6*L 12 -6*L
6*L 2*L^2 -6*L 4*L^2]
Me = m*L/420*[156 22*L 54 -13*L
22*L 4*L^2 13*L -3*L^2
54 13*L 156 -22*L
-13*L -3*L^2 -22*L 4*L^2];
N = length(Ke); % number of degrees of freedom
Kunc = sym(zeros(8,8)); % stiffness matrix of unconstrained beam
Kunc(1:4,1:4) = Kunc(1:4,1:4) + Ke; % element 1
Kunc(3:6,3:6) = Kunc(3:6,3:6) + Ke; % element 2
Kunc(5:8,5:8) = Kunc(5:8,5:8) + Ke; % element 3
iDOFs = [2,3,4,6,7,8]; % DOFs to be retained
K = Kunc(iDOFs,iDOFs) % stiffness matrix of constrained beam
Me = m*L/420*[156 22*L 54 -13*L
22*L 4*L^2 13*L -3*L^2
54 13*L 156 -22*L
-13*L -3*L^2 -22*L 4*L^2];
Munc = sym(zeros(8,8)); % consistent mass matrix of unconstrained beam
Munc(1:4,1:4) = Munc(1:4,1:4) + Me; % element 1
Munc(3:6,3:6) = Munc(3:6,3:6) + Me; % element 2
Munc(5:8,5:8) = Munc(5:8,5:8) + Me; % element 3
M = Munc(iDOFs,iDOFs) % consistent mass matrix of constrained beam
Modal Analysis -- Generalized Eigenvalue Problem
[Phi,Omega2] = eig(K,M); % eigen-analysis
When the code hits the eigen analysis it yeilds a too many input arguments error. Not sure how to address this as K and M are both square matrices.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (2)

Andreas Apostolatos el 30 de Abr. de 2022
Editada: Andreas Apostolatos el 30 de Abr. de 2022
Hi,
The issue here is that you are defining matrices K and M as symbolic matrices,
whos K M
Name Size Bytes Class Attributes
K 6x6 8 sym
M 6x6 8 sym
As Steven mentioned below, calling function eig with symbolic inputs results in having the symbolic version of function eig called. The symbolic version of function eig does not accept two input variables for solving generalized eigenvalue problems. To resolve the issue just convert the symbolic input matrices to numeric ones as follows for instance:
[Phi,Omega2] = eig(double(K),double(M));
and so you will ensure that the numeric version of function eig is called, which indeed accepts two input arguments.
I hope this helps.
Kind regards,
Andreas
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Steven Lord el 30 de Abr. de 2022
Function eig works for numeric and not symbolic inputs.
That's not 100% accurate. There is a version of the eig function that works for symbolic inputs, but the symbolic eig does not support the generalized eigenvalue problem syntax that the numeric eig function does. The symbolic eig function accepts between 1 and 1 data input arguments, where the numeric eig function accepts between 1 and 2 data input arguments (and some option inputs like 'balance' or 'matrix'.) That's why the error message indicates eig is being called with too many inputs rather than indicating that there is no eig method for sym objects.

Iniciar sesión para comentar.

Riccardo Scorretti el 30 de Abr. de 2022
Hi. The problem is not with the size of K and M; the problem is that in your code K and M are symblic variables. Juste convert them to double (see below).
clear; close all; clc
m = 25;
EI = 100;
L = 1;
Ke = EI/L^3*[12 6*L -12 6*L
6*L 4*L^2 -6*L 2*L^2
-12 -6*L 12 -6*L
6*L 2*L^2 -6*L 4*L^2]
Ke = 4×4
1200 600 -1200 600 600 400 -600 200 -1200 -600 1200 -600 600 200 -600 400
Me = m*L/420*[156 22*L 54 -13*L
22*L 4*L^2 13*L -3*L^2
54 13*L 156 -22*L
-13*L -3*L^2 -22*L 4*L^2];
N = length(Ke); % number of degrees of freedom
Kunc = sym(zeros(8,8)); % stiffness matrix of unconstrained beam
Kunc(1:4,1:4) = Kunc(1:4,1:4) + Ke; % element 1
Kunc(3:6,3:6) = Kunc(3:6,3:6) + Ke; % element 2
Kunc(5:8,5:8) = Kunc(5:8,5:8) + Ke; % element 3
iDOFs = [2,3,4,6,7,8]; % DOFs to be retained
K = Kunc(iDOFs,iDOFs) % stiffness matrix of constrained beam
K =
Me = m*L/420*[156 22*L 54 -13*L
22*L 4*L^2 13*L -3*L^2
54 13*L 156 -22*L
-13*L -3*L^2 -22*L 4*L^2];
Munc = sym(zeros(8,8)); % consistent mass matrix of unconstrained beam
Munc(1:4,1:4) = Munc(1:4,1:4) + Me; % element 1
Munc(3:6,3:6) = Munc(3:6,3:6) + Me; % element 2
Munc(5:8,5:8) = Munc(5:8,5:8) + Me; % element 3
M = Munc(iDOFs,iDOFs) % consistent mass matrix of constrained beam
M =
ans = 1×2
6 6
ans = 1×2
6 6
[Phi,Omega2] = eig(double(K), double(M)) % eigen-analysis
Phi = 6×6
-0.1511 0.3405 -0.7951 -0.9053 -2.1375 1.1547 -0.1058 0.1764 0.0326 0.1180 0.1128 0.0298 -0.0211 -0.0854 0.7843 0.3458 -1.2267 1.3763 0.2342 -0.0266 -0.5298 0.9879 0.1963 1.8254 0.3021 0.2180 0.1516 -0.3392 0.2724 0.4193 0.3270 0.3109 0.5228 -1.8691 2.1940 4.2249
Omega2 = 6×6
1.0e+04 * 0.0010 0 0 0 0 0 0 0.0057 0 0 0 0 0 0 0.0594 0 0 0 0 0 0 0.1955 0 0 0 0 0 0 0.5767 0 0 0 0 0 0 1.3773
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by