diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2025-10-20 16:43:28 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2025-10-20 16:43:28 -0600 |
| commit | ba75ac4c0a829316b3cd30cd8110d353cde2b6d2 (patch) | |
| tree | f8fa13b2a239e0eaeaa083ee31e74a1ab70c1cf7 /tutorials/module_4/data_generation.py | |
| parent | d74d4b65a51d11db90198d6f2548d9ab942a2c25 (diff) | |
Added sample data files
Diffstat (limited to 'tutorials/module_4/data_generation.py')
| -rw-r--r-- | tutorials/module_4/data_generation.py | 38 |
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() + + |
