0% found this document useful (0 votes)
8 views2 pages

Eigen Value Eigen Vector

Uploaded by

harshads1502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Eigen Value Eigen Vector

Uploaded by

harshads1502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

12/11/24 12:16 AM C:\Users\...\AMVexp1naturalfrequency.

m 1 of 2

clc
clear

disp(' EIGEN VALUE and EIGEN VECTOR OF SYSTEM for N DOF ' );

n = input('Enter the number of degree of freedom (n) : ' );

if ~isnumeric(n) || n<1 || floor(n) ~= n


error('n must be a integer greater than or equal to 1' );
end

disp('Choose the case:');


disp('1. n DOF, 2 support');
disp('2. n DOF, 1 support:');
disp('3. n DOF, 0 support:');

case_num = input('Enter the case number (1, 2 or 3): ' );

if case_num == 1
disp('You have chosen for n mass, n+1 spring system' );
end

if case_num ==2
disp(['You have chosen for n mass, n spring system. ' ...
'Please enter k1=0 reference to 2 support system.' ]);
end

if case_num == 3
disp(['You have chosen for n mass, (n-1) spring system. ' ...
'Please enter k1=0 and k(n+1)=0, reference to 2 support system. ' ]);
end

M=zeros(n);
K=zeros(n);

disp('Enter the n mass values for each degree of freedom: ' );

for i=1:n
M(i,i) = input(sprintf('Mass m%d: ',i));
end

k = zeros(1,n+1);
disp('Enter the value for stiffness for springs: ' );

for i=1:n+1
k(i)=input(sprintf('Stiffness k%d : ',i));
end
12/11/24 12:16 AM C:\Users\...\AMVexp1naturalfrequency.m 2 of 2

for i=1:n

if i==1
K(i,i)=k(i)+k(i+1);
K(i,i+1)=-k(i+1);

elseif i==n
K(i,i-1)=-k(i);
K(i,i)=k(i)+ k(i+1);

else
K(i,i-1) = -k(i);
K(i,i)=k(i)+k(i+1);
K(i,i+1)=-k(i+1);
end
end

disp('Stiffness Matrix for input Stiffness : ' );


disp(K);

[eigvec, eigval] = eig(K, M);

lambda = diag(eigval);

omegan = sqrt(lambda);

%disp('Eigen Values of this system are :');


%disp(lambda);

for i = 1:n
eigvec(:,i) = eigvec(:,i)/eigvec(1,i);
end

for i = 1:n
fprintf('Eigen Vector corresponding to Eigen Value %.4f : \n' , lambda(i));
disp(eigvec(:, i));
fprintf('and Corresponding Natural Frequency is %.4f: ' , omegan(i));
fprintf('\n\n');

end

You might also like