summaryrefslogtreecommitdiff
path: root/tutorials/module_4/data_generation.py
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/module_4/data_generation.py')
-rw-r--r--tutorials/module_4/data_generation.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tutorials/module_4/data_generation.py b/tutorials/module_4/data_generation.py
new file mode 100644
index 0000000..7656834
--- /dev/null
+++ b/tutorials/module_4/data_generation.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+Created on Mon Oct 20 14:40:48 2025
+
+@author: christian
+"""
+
+import numpy as np
+import pandas as pd
+import matplotlib.pyplot as plt
+
+# Parameters
+A = 1.0 # initial amplitude
+b = 0.2 # damping coefficient
+f = 1.0 # frequency (Hz)
+time = np.linspace(0, 5, 1000) # time vector
+
+# Dampened sine wave formula
+displacement = A * np.exp(-b * time) * np.sin(2 * np.pi * f * time)
+
+velocity = np.gradient(displacement, time)
+acceleration = np.gradient(velocity,time)
+
+# Plotting
+plt.figure(figsize=(8, 5))
+plt.plot(time, displacement, label='disp. (m)', color='blue')
+plt.plot(time, velocity, label='vel. (m/s)', color='red')
+plt.plot(time, acceleration, label='acc. (m/s^2)', color='black')
+plt.title('Pendulum')
+plt.xlabel('Time (s)')
+plt.ylabel('f(t)')
+plt.grid(True)
+plt.legend()
+plt.tight_layout()
+plt.show()
+
+