MATLAB: How to solve this matrix for y

MATLABmatricesmatrix arraymatrix manipulationvibrations

M = [1 0 0 0; 0 1 0 0; 0 0 20 0; 0 0 0 10]; % Mass matrix
y = [x1; x2; v1; v2]; % Displacement & Velocity Matrix
B = [0 0 -1 0; 0 0 0 -1; -2 2 -2 2; 1 -1 1 -1]; % Spring Matrix
C = [0; 0; 0; -1]; % Force Matrix
I'm following an example:
At the bottom of the page, Frequency vs Amplitude is achieved. That's what I'm trying to do.

Best Answer

See ode45()
tspan = [0; 10];
IC = [1 1 0 0]; % initial condition
[t, Y] = ode45(@odeFun, tspan, IC);
plot(t, Y);
legend({'x_1', 'x_2', 'v_1', 'v_2'});
function dYdt = odeFun(t, Y)
M = [1 0 0 0; 0 1 0 0; 0 0 20 0; 0 0 0 10]; % Mass matrix
B = [0 0 -1 0; 0 0 0 -1; -2 2 -2 2; 1 -1 1 -1]; % Spring Matrix
C = [0; 0; 0; -1]; % Force Matrix
dYdt = M\(C - B*Y);
end