VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY
UNIVERSITY OF TECHNOLOGY
GENERAL PHYSICS 1 PROJECT
REPORT
EXAMINING AND USING MATLAB SYMBOLIC
CALCULATION TO SOLVE ABOUT EQUATION OF
HARMONIC OSCILLATION
Theory Instructor: Prof. Nguyen Thi Thuy Hang
Exercise Instructor: Prof. Nguyen Thi Minh Huong
Theory class: CC23 & Exercise class: CC40 & Group: 12
Members:
1. Ho Quang Huy - 2551595
2. Dinh Ngoc Hoang Phuc - 2551612
3. Vuu Huynh Gia An - 2550255
4. Dang Le Nhat Quang - 2551615
5. Do Minh Hieu - 2551593
Ho Chi Minh City - November, 2025
Table of contents
1. INTRODUCTION
2. THEORETICAL BASIS
3. MATLAB
3.1 Solving the problem using
symbolic calculation and graphical
interpretation
3.2 Code MATLAB and explanation
3.3 Results and discussion
4. CONCLUSION
4.1 References
1. Introduction
Oscillation is a fundamental phenomenon in classical physics, describing a
repetitive motion around an equilibrium point. In this project, we will
investigate and calculate the oscillations of any body due to elastic force.
Another aim of this project is to understand and utilize a powerful tool essential in
engineering fields- MATLAB. So, all of the theoretical solutions and motion
figures were conducted and simulated by using MATLAB. All of the algorithms
and codes used in this project will be presented and explained in this report.
2. Theoretical basis
2.1 Overview
The oscillated motion of the investigated body can be described by this differential
equation:
+ ω+ 𝑏 𝑡 = 𝐹𝑐𝑜𝑠(ω𝑡)
𝑑2 𝑦 𝑑𝑦 2
𝑑𝑡 0
2
Where: 𝑑𝑡
- y(t) is the displacement of the body from equilibrium point at time t.
- b is the damped coefficient.
- ω0 is the natural angular frequency of the free oscillation.
- F is the stimulating force.
- ω is the angular frequency of the external force.
Equation explanation:
This equation is the sum of 3 components:
1. Acceleration of the body:
2
𝑑 𝑦
2
𝑑𝑡
is the second derivative of position y with respect to time t. This term represents
the acceleration of the body in the system.
2. Damping term of the body:
𝑑𝑦
�𝑑𝑡
�
Damped coefficient b shows how much friction the system has, which directly
affects the oscillation.
3. Elastic force:
This is the basis formula of natural angular frequency of the free oscillation:
ω = 𝑘
0 𝑚
So that the component:
ω𝑡
2
0
represents the elastic force, which tries to pull the body back to the equilibrium
point.
2.2 Overview Of Three Oscillation Responses
This project will investigate three scenarios:
a) Harmonic oscillation ( ω0 = 3; b = F = 0; t = 20s)
This is the simplest case, there is no damped, no stimulated force. The
differential equation become:
+ ω0 𝑡 = 0
2
𝑑 𝑦 2
𝑑𝑡2
driving force, where the natural frequency is defined as ω = 3, with initial
This inquiry studied a simple harmonic oscillator with no damping and no
0
conditions y(0)= 5, y'(0)= 0.
The goal of this inquiry is to show the free oscillation in the idealized scenario
( no damped, no stimulated force).
b) Damped oscillation( ω0 = 10; b = 0.01, 0.1, 1.0, 10.0 ; F = 0; t = 20s)
In this scenario, the system starts from the same initial conditions, and only the
damping value changes. The purpose is to observe how damping affects the
oscillations:
+2 ω+ 𝑏 𝑡 = 𝐹𝑐𝑜𝑠(ω𝑡)
𝑑2 𝑦 𝑑𝑦 2
𝑑𝑡 𝑑𝑡 0
We will substitute many values of damped coefficient b to investigate the effects
of b on the oscillations.
c) Stimulated oscillation(ω0 = 10; b= 0.1 ; F = 0; ω= 10.0, 5.0, 3.0, 0.0; t
= 150s)
Starting with the same initial conditions as the first two scenarios (y(0)= 5; y’(0)
= 0), we only substitute ω values.
+2 ω+ 𝑏 𝑡 = 𝐹𝑐𝑜𝑠(ω𝑡)
𝑑2 𝑦 𝑑𝑦 2
𝑑𝑡 𝑑𝑡 0
3. MATLAB
3.1) Solving the problem using
symbolic calculation and graphical
interpretation
Some useful functions used in the code to investigate three scenarios in this
report:
Operator/Functio Purpose Example
n
Semicolon (;) end of statement clear all; % Clear memory
% a comment
clear deletes all (or the clear x;
specified) variable(s) from
the memory.
clf Clear graphics figure clf;
window
clc Clears command window
syms Declares variables syms x %symbolic variable x
Colon (:) generates regularly spaced for iCharge = 1:NCharges;
elements, creates vectors x = [-10 : 0.01 : 10];
and represents an entire
row or column
asterisk (*) Scalar and matrix 4*pi*Epsilonα
multiplication operator.
^ Scalar and matrix R = sqrt(x^2 + y^2);
exponentiation operator. C^2/(N m^2)
Parentheses ( ) encloses function Fx = Fx+ q(iCharge)*q(jCharge)*xij/Rij^3;
arguments and array x=
indices dsolve('D2y=(-dmdt*eu)/(m0+dmdt*t)-
g','Dy(0)=0','y( 0)=0');
Brackets [ ] encloses array elements.
== Equal to if( x == 1 )
~= Not equal to if( x ~= 1 )
fplot Intelligent plotting of xplot(i)=xfunc(aalpha, hh, mm, tplot(i), vv0);
functions. yplot(i)=yfunc(aalpha, gg,hh,mm, tplot(i),vv0);
grid Displays gridlines.
plot Generates xy plot plot(xplot,yplot)
xlabel Adds text label to x-axis. xlabel('Range (m)');
title Puts text at top of plot.
disp Display words on the Disp (‘Amazing good job ☺’);
screen
figure Opens a new figure
window.
for for loop for(x ~= 0)
iterate over a sequence of y = x/2;
items
dsolve Solves differential Let us take up a simple example of a first order
equations symbolically differential equation: y' = 5y.
s = dsolve('Dy = 5*y')
the result: s = C2*exp(5*t)
diff computes symbolic syms t
derivatives f = 3*t^2 + 2*t^(-2);
diff(f)
ans =
6*t - 4/t^3
diff(f,n) computes higher f = x*exp(-3*x);
derivatives of a function f diff(f, 2)
ans =
9*x*exp(-3*x) - 6*exp(-3*x)
from Matlab projects, Physics 1, FAS, HCMUT
3.2) Code MATLAB and explanation
❖ Flowchart:
a) Harmonic oscillation ( ω0 = 3; b = F = 0; t = 20s)
%% 1. HARMONIC OSCILLATION (no damping, no forcing)
%% ==============================================================
fprintf('\n========== TASK A – HARMONIC OSCILLATION ==========\
n');
% declaring symbolic
variables syms y(t)
Dy = diff(y,t);
D2y =
diff(Dy,t);
w0 = 3; % natural angular frequency
b = 0; % no damping
F = 0; % no external
force ode = D2y + b*Dy + w0^2*y == F; % RHS is
zero
conds = [y(0)==5, Dy(0)==0]; % initial
conditions S = dsolve(ode,conds); % symbolic
solution
% graph simulated figure
figure;
fplot(S,[0 20],'LineWidth',1.5);
xlabel('Time (t) [s]'); ylabel('Displacement
y(t)'); title('Harmonic Oscillation (undamped,
unforced)'); grid on;
fprintf('Harmonic-oscillation equation:\
n'); disp(S);
b) Damped oscillation
fprintf('\n========== TASK B – DAMPED OSCILLATION ==========\n');
% --- parameters ------------------------------------------------
omega0 = 10; % natural frequency
t_end = 20; % simulation time
b_values = [0.01 0.1 1 10]; % four damping
coefficients initial_conditions = [5; 0]; % y(0)=5,
y'(0)=0
% ---------------------------------------------------------------
figure;
for k = 1:numel(b_values) % to create a loop that goes through
every elements in b_values
b = b_values(k);
zeta = b/(2*omega0); % damping ratio
ode_fun = @(t,x) [ x(2); ...
-b*x(2) - omega0^2*x(1) ]; % F = 0
[t,x] = ode45(ode_fun,[0
t_end],initial_conditions); y = x(:,1);
subplot(numel(b_values),1,k);
plot(t,y,'LineWidth',1.2);
title(sprintf('b = %.2f, \\zeta = %.3f',b,zeta), 'Interpreter', 'tex');
xlabel('t [s]'); ylabel('y(t)'); grid
on; end
sgtitle('Damped Oscillation for Several Damping Coefficients');
c) Stimulated oscillation
fprintf('\n========== TASK C – STIMULATED OSCILLATION ==========\n');
syms y(t) t
syms b omega0 F omega
% calculating differential equations using
symbolic Dy = diff(y,t);
D2y = diff(y,t,2);
ode = (D2y+ b*Dy+ omega0^2*y == F*cos(omega*t));
% initial conditions
cond1 = y(0) == 5;
cond2 = Dy(0) == 0;
conds = [cond1,
cond2];
% task c parameters
y_sol = dsolve(ode, conds);
omega0_c = 10;
b_c = 0.1;
F_c = 10;
omega_values = [10.0, 5.0, 3.0, 0.0];
t_range = [0
150]; figure;
for i = 1:length(omega_values)
current_omega =
omega_values(i);
% to create a loop that goes through every elements in
omega_values sol_c = subs(y_sol, [omega0, b, F, omega],
[omega0_c, b_c, F_c,
current_omega]);
subplot(4,1,i);
% to create four graphs respectively
fplot(sol_c,t_range);
title_str = sprintf('Stimulated Oscillation: \\omega_0= %.1f, \\omega=
%.1f', omega0_c, current_omega);
title(title_str);
ylabel('Displacement y(t)');
xlabel('Time (t) in seconds');
grid on;
end
sgtitle('Comparison of Stimulated Oscillations for Different
Driving Frequencies');
disp('Task (c) plot created');
3.3) Results and discussions
a) HARMONIC OSCILLATION ( ω0 = 3; b = F = 0; t
= 20s)
This is the simplest case, there is no damped, no stimulated force. The
differential equation become:
+ ω0 𝑡 = 0
2
𝑑 𝑦 2
𝑑𝑡2
driving force, where the natural frequency is defined as ω = 3, with initial
This inquiry studied a simple harmonic oscillator with no damping and no
0
conditions y(0)= 5, y'(0)= 0.
The goal of this inquiry is to show the free oscillation in the idealized scenario
( no damped, no stimulated force).
Observation:
The plot produced displays a consistent oscillation that has a fixed
amplitude and a fixed period. The solution is initialized at a maximum
displacement of 5 units and then oscillates symmetrically up and down
about zero. The peaks and troughs of the wave reproduce consistently for
the entire 20s observation period, indicating perfect periodic motion.
Since b (the damping coefficient) and F (driving force) = 0, there was
perfect oscillation that continued without changes throughout the entire
task's duration.
The frequency of oscillation is determined by the natural frequency ω0=3
=> T = 2π/ ω0 = 2π/3 ≈ 2.094 s. The period of oscillation aligns with the
spacing of the peaks in the plot, validating the theoretical expectations.
Conclusion:
Task (a) illustrates well the behavior of a simple harmonic oscillator if
left alone. The initial conditions provided a smooth, repetitive oscillation
with a constant amplitude and a fixed frequency. Because there is no
damping and no external driving force of any type, the oscillation solely
depends on the natural frequency of the system and the initial conditions.
This task provides a clear understanding of simple harmonic oscillators
and serves as an important starting point to investigate more complex
forms of oscillatory motion.
b) DAMPED OSCILLATION ( ω0 = 10; b = 0.01, 0.1, 1.0,
10.0 ; F = 0; t = 20s)
In this scenario, the system starts from the same initial conditions, and only the
damping value changes. The purpose is to observe how damping affects the
oscillations.
ζ= 𝑏 2ω
0
In a damped oscillator, the damping ratio
Case 1 — b = 0.01, ζ = 0.0005
- The oscillations have high amplitude and persist throughout the
entire 20-second interval.
- The decay is so slow that the waveform appears almost undamped.
- The system completes many cycles with almost no loss of energy.
Conclusion: Very light damping → oscillations remain strong for a long time.
Case 2 — b = 0.1, ζ = 0.005
- The amplitude still remains relatively large, but a gradual decay is visible.
- The oscillations stay clean and sinusoidal.
- Energy loss per cycle becomes noticeable compared to the first case.
Conclusion: Light damping → oscillations decay slowly but the reduction in
amplitude is now clear.
Case 3 — b = 1, ζ = 0.05
- The amplitude decays much faster than in the previous two cases.
- After a few seconds, the oscillations become small and eventually
fade out.
- The number of visible cycles is significantly reduced.
Conclusion: Moderate damping → oscillations die out quickly and the system
settles near equilibrium.
Case 4 — b = 10, ζ = 0.5
- Oscillations are almost completely suppressed.
- Only a brief initial movement occurs before the system
rapidly approaches a steady value.
- Practically no oscillatory behavior remains.
Conclusion: Heavy damping → system returns to rest very quickly with little to no
oscillation.
Task B conclusion:
- Increasing the damping coefficient results in faster decay and
fewer visible oscillations.
- The character of the motion transitions smoothly from slowly
decaying oscillations (b = 0.01) to almost non-oscillatory motion (b =
10).
- This demonstrates the fundamental effect of damping: stronger
damping leads to faster energy dissipation and rapid stabilization of the
system.
c) STIMULATED OSCILLATION:
DETAILED EXPLANATION OF THE CASES
From the conditions provided in the problem, we have:
o Natural frequency: ω0 = 10
o Damping: b = 0.1
o Driving amplitude: F = 10
o Initial conditions: y(0) = 5 & y’(0) = 0
o Simulation time: t = 150s
o Only the driving frequency ω is changed
CASE 1: ω = 10.0, b = 0.1, F = 10, ω0 = 10 ( ω = ω0 )
In this case, the driving frequency is the same as the natural frequency.
From the graph, we observe that:
+ Even with damping b = 0.1, the amplitude increases quickly at the beginning.
+ After that, the motion reaches a steady oscillation with a large amplitude.
+ Because damping is small (b = 0.1), the amplitude does not grow forever,
but it is still the biggest among all cases.
+ This case happens because the system is in resonance, since the driving
frequency equals its natural frequency.
⇨ This case has the biggest and strongest oscillation.
CASE 2: ω = 5.0, ω0 = 10, b = 0.1, F = 10 ( ω < ω0 )
In this case, the driving frequency is lower than the natural frequency.
From the graph, we observe that:
+ The oscillation still decays at the beginning because of damping.
+ The steady-state amplitude is much smaller than the first case.
+ There is no resonance, so the response is weaker and smoother.
⇨ This case is a kind of medium response with no strong
oscillation. CASE 3: ω = 3.0, ω0 = 10, b = 0.1, F = 10
In this case, the driving frequency is even lower.
From the graph, we observe that:
+ The oscillation dies down faster at the beginning.
+ The steady-state oscillation has a very small amplitude.
+ The system doesn’t react strongly because the driving frequency is far from ω0
⇨ This case shows a weak response and a very small steady-
state amplitude.
CASE 4: ω = 0.0 ( constant force ), ω0 = 10, b = 0.1, F = 10
In this case, the driving force becomes a constant force (no oscillation). From
the graph, we observe that:
+ When ω = 0, the driving force becomes a constant force (not oscillating).
+ The system only shows a short damped oscillation at the beginning.
+ Because of damping (b = 0.1),the motion almost stops oscillating.
+ Since the force is constant, the system cannot maintain any periodic motion.
⇨ This case has no sustained oscillation and the motion dies out
because the force is constant.
CONCLUSION OF PART C
In Task C, we were able to model the driven oscillator and observe how it
reacts under different driving frequencies. From the results, it’s clear that the
system’s response depends a lot on the value of ω. The amplitude becomes the
largest when the driving frequency is close to the natural frequency
(resonance), and it gets smaller as ω has the value which is farther away from
ω₀.
4. Conclusion
In this report, we successfully investigate the study of oscillation caused by
elastic force using MATLAB. We consider that MATLAB is an effective tool in
engineering fields, which can shorten the computing time and simplify any
complicated equations easily.
Furthermore, we want to show gratitude to this project for the valuable
experiences and knowledge. The accomplishment in using MATLAB and deep
understanding about elastic force and oscillation, which we gain through this
project is crucially important for our career in the future.
Additionally, we would like to extend a special thanks to our theory
instructor, Prof. Nguyen Thi Thuy Hang, and our exercise instructor, Prof.
Nguyen Thi Minh Huong, for their guidance and support throughout this
project.
4.1 References
1. Useful functions document from Matlab projects- Physics 1,
Applied Physics Department, FAS, HCMUT
2. Young, H. D. & Freedman, R. A. University Physics with
Modern Physics. 429-433.
3. Serway, R. A. ,& Jewett, J. W. Physics for Scientists and Engineers.
404-405.