-
Notifications
You must be signed in to change notification settings - Fork 22
/
vtb4_1.m
executable file
·50 lines (40 loc) · 1.07 KB
/
vtb4_1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [P,w,S]=vtb4_1(M,K)
%VTB4_1 Natural frequencies and eigenvectors for an undamped
%system.
% [P,w,S]=VTB4_1(M,K) will return the natural frequencies (w),
% eigenvectors (P), and mass normalized mode shapes (S = [u1, u2...])
% for an undamped system.
% The inputs are the mass matrix M and the stiffness matrix K.
% [P,w,S]=VTB4_1(M,K,1) will also print the output of the function
% to the screen.
%Calculates eigenvectors and eigenvalues
U=chol(M);
[P,lam]=eig(U'\K/U);
[w,k]=sort(sqrt(diag(lam)));
P=P(:,k);
% Makes sure the first entry of every column is positive. Looks
% nicer for some modes. No practical use for it.
for i=1:length(M)
if P(1,i)<0
P(:,i)=-P(:,i);
end
end
S=U\P;
if nargout==0
disp('The natural frequencies are')
disp(' ')
for i=1:length(M)
disp(['omega',num2str(i),' = ',num2str(w(i)),' rad/s'])
end
disp(' ')
disp('The eigenvectors of the system are')
P
disp(' ')
disp('The mode shapes of the system are')
U
disp(' ')
disp('The modal transformation matrix S is')
S
end
%Automatically check for updates
vtbchk