Eig Argument Command Error
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
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 comentario
Steven Lord
el 30 de Abr. de 2022
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.
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]
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
[Phi,Omega2] = eig(double(K), double(M)) % eigen-analysis
0 comentarios
Ver también
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!