%---------------------------------------------------------
% C_MATRICES.M
% building the FE mass and stiffness matrices of the model
% and computing its dynamic modes
% Fiala Peter
% 2008 BME, Laboratory of Acoustics
%---------------------------------------------------------
clear all;
close all;
clc;
%%
load data/boxmesh
%% FE mass and stiffness matrices
[m, k, mdof] = fe_mk(box, 'Options', [0 2]);
%% Constraint (z = 0 plane clamped)
nodez0 = feutil('findnode z == 0', box.Node, box.Elt);
DOFind = fe_c(DOF, nodez0, 'ind', 2);
m = m(DOFind,DOFind);
k = k(DOFind,DOFind);
freeDOF = DOF(DOFind);
save data/boxmesh freeDOF -append
%% Modal analysis
[phi, om] = fe_eig(m, k, [3 200 1 0 1e-5]);
save data/boxmodes phi om
%% Display modes
figure(1);
n = 1;
plot_free_model(SDT2Free(box), freeDOF, phi(:,n), 1);
xlabel('x [m]');
ylabel('y [m]');
zlabel('z [m]');
axis equal;
axis tight;
view(15, 25);
%% Display modal density
figure(2);
plot(om/2/pi, 1:length(om));
ylabel('n [-]');
xlabel('f_n [Hz]');