0% found this document useful (0 votes)
44 views3 pages

Spring-Mass System 02

This document describes simulations of a spring-mass system using MATLAB. It contains MATLAB code to: 1) Simulate the system with unit mass, stiffness, and damping. 2) Simulate the system with different masses (m1=5, m2=1) to analyze the effect of unequal masses. 3) Simulate cases with low (k=0.1) and high (k=10) stiffness to analyze the effect of stiffness variations.

Uploaded by

Ali Saleh
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)
44 views3 pages

Spring-Mass System 02

This document describes simulations of a spring-mass system using MATLAB. It contains MATLAB code to: 1) Simulate the system with unit mass, stiffness, and damping. 2) Simulate the system with different masses (m1=5, m2=1) to analyze the effect of unequal masses. 3) Simulate cases with low (k=0.1) and high (k=10) stiffness to analyze the effect of stiffness variations.

Uploaded by

Ali Saleh
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/ 3

Spring-Mass System 02

1. Blank
2. Blank
We used MATLAB, and this is the code
clear all
xo=[1; 0; 0; -2; 1; 0];
ts=[0 30];
[t,x]=ode45('f',ts,xo);
plot(t,x(:,1),t,x(:,2),'--',t,x(:,3))

This is the function (f) which called in the previous code


function v=f(t,x)
m1=1; m2=1;
k1=1; k2=1; k3=1; k4=1;
c1=1; c2=1; c3=1; c4=1;
M=[m1 0 0; 0 m1*sind(45) 0; 0 0 m2];
K=[k1+k3 k2*cosd(45) -k3; 0 k2*sind(45) 0; -k3 0 k3+k4];
C=[c3 c2*cosd(45) -c3; 0 c2*sind(45) 0; -c3 0 c3+c4];
A1=[zeros(3) eye(3); -inv(M)*K -inv(M)*C];
v=A1*x
eigenvalues=eig(A1)

3. Set m=k=c=1 and compute the eigenvalues of the first order


system.
eigenvalues =
-1.2762 + 1.0718i
-1.2762 - 1.0718i
-0.2238 + 1.0149i
-0.2238 - 1.0149i
-0.5000 + 0.8660i
-0.5000 - 0.8660i

4. Simulate the oscillation of the case m=k=c=1.

5. Simulate and discuss case m1>m2.


Here we set m1=5 and m2=1 and this is the code
function v=f(t,x)
m1=5; m2=1;
k1=1; k2=1; k3=1; k4=1;
c1=1; c2=1; c3=1; c4=1;
Spring-Mass System 02
M=[m1 0 0; 0 m1*sind(45) 0; 0 0 m2];
K=[k1+k3 k2*cosd(45) -k3; 0 k2*sind(45) 0; -k3 0 k3+k4];
C=[c3 c2*cosd(45) -c3; 0 c2*sind(45) 0; -c3 0 c3+c4];
A1=[zeros(3) eye(3); -inv(M)*K -inv(M)*C];
v=A1*x
eigenvalues=eig(A1)

6. Simulate and discuss the case k=0.1 for chosen input signal
and/or initial conditions.
function v=f(t,x)
m1=1; m2=1;
k1=1; k2=1; k3=1; k4=1;
c1=0.1; c2=0.1; c3=1; c4=1;
M=[m1 0 0; 0 m1*sind(45) 0; 0 0 m2];
K=[k1+k3 k2*cosd(45) -k3; 0 k2*sind(45) 0; -k3 0 k3+k4];
C=[c3 c2*cosd(45) -c3; 0 c2*sind(45) 0; -c3 0 c3+c4];
A1=[zeros(3) eye(3); -inv(M)*K -inv(M)*C];
v=A1*x
eigenvalues=eig(A1)

7. Simulate and discuss the case k=10 for chosen input signal
and/or initial conditions.
function v=f(t,x)
m1=1; m2=1;
k1=1; k2=1; k3=1; k4=1;
c1=10; c2=10; c3=10; c4=1;
M=[m1 0 0; 0 m1*sind(45) 0; 0 0 m2];
K=[k1+k3 k2*cosd(45) -k3; 0 k2*sind(45) 0; -k3 0 k3+k4];
C=[c3 c2*cosd(45) -c3; 0 c2*sind(45) 0; -c3 0 c3+c4];
A1=[zeros(3) eye(3); -inv(M)*K -inv(M)*C];
v=A1*x
eigenvalues=eig(A1)
Spring-Mass System 02

You might also like