Lab 1 - System Response Using MatLab
Lab 1 - System Response Using MatLab
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
1. Open 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.
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 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.
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:
k
m f(t)
Step 1. Create the following model in Simulink using variables (k, m, c, etc.)
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')
Step 6. Replace the source with Constant (value = 0) and connect as an input.
Step 7. Set the initial condition (x0, x0_dot) on Integrator in the Simulink model. Open
property of an integrator block by double click.
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')
0.02
-0.01
-0.02
-0.03
0 10 20 30 40 50 60
Time (sec)
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.
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)