0% found this document useful (0 votes)
13 views

Matlab Code For Natural Freq

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

Matlab Code For Natural Freq

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

% Define system parameters

m = [1; 1; 1]; % Masses [m1; m2; m3]

k = [10; 10; 10]; % Spring constants [k1; k2; k3]

% Mass matrix (Diagonal matrix with masses)

M = diag(m);

% Stiffness matrix

K = [k(1) + k(2), -k(2), 0;

-k(2), k(2) + k(3), -k(3);

0, -k(3), k(3)];

% Compute natural frequencies and mode shapes

[phi, lambda] = eig(inv(M) * K); % eigenvectors (phi) and eigenvalues (lambda)

% Natural frequencies

omega = sqrt(diag(lambda)); % Convert eigenvalues to natural frequencies (rad/s)

f = omega / (2 * pi); % Convert to Hz

% Display natural frequencies

disp('Natural Frequencies (Hz):');

disp(f);

% Plot mode shapes

figure;

for i = 1:size(phi, 2)

subplot(size(phi, 2), 1, i);

plot(phi(:, i), 'o-');

title(['Mode Shape ', num2str(i)]);

xlabel('DOF');

ylabel('Amplitude');
end

sgtitle('Mode Shapes of the 3 DOF System');

You might also like