You are on page 1of 8

ME 4501 Vibrations & Controls Laboratory

System Response Using MATLAB / Simulink


Due dates: 1 week

Each individual will do the work on the Lab assignment and submit your work in D2L.
MATLAB code and figures (Simulink models and plots) should be submitted as well.

Objectives
Using both Matlab command window and Matlab Simulink.
1. Introduce and practice modeling and simulating dynamic system responses
2. Define the transfer function
3. Locate poles and zeros of the system
4. Find the system response to unit step and various input functions

Lab Practice I. MATLAB Review


See the PPT (D2L)

Lab Practice II. Simulating Systems using transfer function

1. Open Simulink

Click “Simulink” button or type >> simulink in command window

Figure 2. How to start Simulink

Open a blank model, you can find the Simulink components in “Library Brower”

Figure 3. Library Browser in Simulink. You can find each component here.

2. Transfer function using MATLAB Simulink

Example: Find the response of the system for 𝒓(𝒕) = 𝟏𝟎 ∗ 𝒔𝒊𝒏(𝟓𝒕)

Step 1. Add the input to the model Sine wave (Sources). Double click and change the
amplitude and the frequency.

Step 2. Define transfer function: Select continuous from Simulink Library and then
select transfer function and drag it into the model. Double click and define the
numerator and the denominator of the transfer function.
D. Kim Lab 6 Page 1 of 8
ME 4501 Vibrations & Controls Laboratory

Step 3. Add a scope.

Figure 4. Transfer function model in Simulink

Step 4. Before you run the simulation, you need to change the configurations as
follows. (MODELING → Model Setting).
Select Solver tap, and change the variables as follows.
• Simulation time: Start Time (0.0), Stop time (10.0)
• Solver selection: Type (Fixed-Step), Solver (ode4 (Runge-Kutta))
• Then, open the solver details, and Set “Fixed-step size to 0.01.
Select Data Import/Export, and set the variable name for Time and Output as you
want (or leave as it is). Then press OK.

Figure 5. Configuration for Simulink simulation

Step 5. Run Simulation (SIMULATION → RUN). Once you run the simulation and
double click on the scope, you will be able to plot the response of the system:

Figure 6. How to run a model in Simulink

D. Kim Lab 6 Page 2 of 8


ME 4501 Vibrations & Controls Laboratory

Figure 7. Response on the scope in Simulink.

Lab Practice III. Modeling in Simulink

A. Step Input simulation using Simulink


x(t)

k
m f(t)

Figure 8. Mass-spring-damper system.

The equation of motion is as follows


𝑚𝑥̈ + 𝑐𝑥̇ + 𝑘𝑥 = 𝑓(𝑡)
We can rewrite this as follows.
1
𝑥̈ = (𝑓(𝑡) − 𝑐𝑥̇ − 𝑘𝑥 )
𝑚

Step 1. Create the following model in Simulink using variables (k, m, c, etc.)

Figure 9. Example of the Simulink model

D. Kim Lab 6 Page 3 of 8


ME 4501 Vibrations & Controls Laboratory

Table 1. Simulink Component.


Integrator Constant value
* Initial Condition: 0
Gain Step input (Source)
* Step time: 0
Sum Sine Wave
* List of signs: 3 (Source)
Add Pulse generator
(Source)
Scope To Workspace
* Variable name: x
* Save format: Array
• Detailed explanations in PPT

Step 2. Configurating the simulation using variables


• Simulation time: Start Time (t0), Stop time (tfinal)
• Solver selection: Type (Fixed-Step), Solver (ode4 (Runge-Kutta))
• Then, open the solver details, and Set “Fixed-step size to dt.
• Select Data Import/Export, and set the variable name ‘tout’ for Time. Uncheck
‘single simulation output’.

Step 4. Save the Simulink model file (e.g., sim_model.slx)

Step 5. Create a following code in a script file (*.m) and run. “sim” is a function which
runs a Simulink model. The variables used in a Simulink model should be defined before
simulation.

%% Setting
clear % delete all variable
close % close all figures
clc % clear command window
% parameters
m = 1; % mass (kg)
c = 0.2; % damper(Ns/m)
k = 10; % stiffness (N/m)
t0 = 0; % start time
tfinal = 60; % final time
dt = 0.01; % fixed step size
sim('sim_model') % simulation
%% plot
figure(1); % figure 1
plot(tout, x, 'k') % plot t vs. x
xlabel('Time (sec)')
ylabel('Displacement x (mm)')
title('Responses of a mass-spring-damper system')

D. Kim Lab 6 Page 4 of 8


ME 4501 Vibrations & Controls Laboratory

Figure 10. Simulation result of Lab Practice III-A

B. Free vibration simulation using Simulink

Step 6. Replace the source with Constant (value = 0) and connect as an input.

Figure 11. Example of the Simulink model 2

Step 7. Set the initial condition (x0, x0_dot) on Integrator in the Simulink model. Open
property of an integrator block by double click.

D. Kim Lab 6 Page 5 of 8


ME 4501 Vibrations & Controls Laboratory

Figure 12. Example of the Simulink model 2

Step 8. Save the Simulink model file as another file name (sim_model2.slx).

Step 9. Create a following code in a script file (*.m) and run. Again, the variables used in
a Simulink model should be defined before simulation.

%% Setting
clear % delete all variable
close % close all figures
clc % clear command window
% parameters
m = 1; % mass (kg)
c = 0.2; % damper(Ns/m)
k = 10; % stiffness (N/m)
t0 = 0; % start time
tfinal = 60; % final time
dt = 0.01; % fixed step size
x0 = 0.03;
x0_dot = 0;
sim('sim_model2.slx') % simulation

%% plot
figure(1); % figure 1
plot(tout, x, 'k') % plot t vs. x
xlabel('Time (sec)')
ylabel('Displacement x (mm)')
title('Responses of a mass-spring-damper system')

D. Kim Lab 6 Page 6 of 8


ME 4501 Vibrations & Controls Laboratory

Responses of a mass-spring-damper system


0.03

0.02

Displacement x (mm) 0.01

-0.01

-0.02

-0.03
0 10 20 30 40 50 60
Time (sec)

Figure 13. Simulation result of Lab Practice III-B

D. Kim Lab 6 Page 7 of 8


ME 4501 Vibrations & Controls Laboratory

Lab Assignment
Solve the following problems using the MATLAB. You need to copy the Simulink model
and MATLAB code in the report. You should submit the code and Simulink model as
well.

1. Consider the following system.


x1(t), f1(t) x2(t), f2(t)

k1 k2 k3
m1 m2

c1 c2 c3

A. Derive the equations of motion and write the equations in the following format:

𝑥̈ 1 =

𝑥̈ 2 =

B. Build a Simulink model for the above 2DOF mass-spring-damper system. Use the
following parameters: m1 = 1 kg; m2 = 1 kg; k1 = 10 N/m; k2 = 10 N/m; k3 = 10 N/m; c1
= 0.2 Ns/m; c2 = 0.2 N-s/m; c3 = 0.2 N-s/m. Obtain the responses: x1(t) and x2(t) for the
following conditions: (set the final simulation time to see a steady-state response)

a. 𝑥1 (0) = 0.05, 𝑥2 (0) = 0, 𝑥̇ 1 (0) = 𝑥̇ 2 (0) = 0, 𝑓1 (𝑡) = 𝑓2 (𝑡) = 0

b. 𝑥1 (0) = 𝑥2(0) = 0, 𝑥̇ 1(0) = 𝑥̇ 2 (0) = 0, 𝑓1 (𝑡) = 0.5 sin 𝜋𝑡 , 𝑓2 (𝑡) = 0

c. 𝑥1 (0) = 𝑥2(0) = 0, 𝑥̇ 1(0) = 𝑥̇ 2 (0) = 0, 𝑓1 (𝑡) = 0, 𝑓2 (𝑡) = 0.5 sin 𝜋𝑡

d. 𝑥1 (0) = 𝑥2(0) = 0, 𝑥̇ 1(0) = 𝑥̇ 2 (0) = 0, 𝑓1 (𝑡) = 0, 𝑓2 (𝑡) is shown in below.


f2(t)
1N

0 60 120 180 240 300 t (sec)

D. Kim Lab 6 Page 8 of 8

You might also like