0% found this document useful (0 votes)
5 views

2104.ipynb - Colab

Uploaded by

monkeiydluffy752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

2104.ipynb - Colab

Uploaded by

monkeiydluffy752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

06/11/2024, 11:19 2104035.

ipynb - Colab

import numpy as np
import matplotlib.pyplot as plt

Fo = 5 # Base frequency (Hz)


Fs1 = Fo + 2 # Fs1 = 10 Hz
Fs2 = Fo * 2 # Fs2 = 16 Hz
k_values = [1, 0, 3] # k values
duration = 1 # 1 second duration
sampling_rate = 1000 # High sampling rate for smooth plots

# Time vector
t = np.linspace(0, duration, sampling_rate, endpoint=False)

# Function to generate waves


def generate_wave(k, Fs1, Fs2, t):
wave_Fs1 = np.sin(2 * np.pi * (Fs1 + k * Fs1) * t)
wave_Fs2 = np.sin(2 * np.pi * (Fs2 + k * Fs2) * t)
return wave_Fs1, wave_Fs2

# Plot the waves for each k value


plt.figure(figsize=(20, 8))

for i, k in enumerate(k_values):
wave_Fs1, wave_Fs2 = generate_wave(k, Fs1, Fs2, t)

# Create a subplot for each k value


plt.subplot(3, 1, i + 1)
plt.plot(t, wave_Fs1, label=f'Fs1, k = {k}', color='b', linewidth=1.5)
plt.plot(t, wave_Fs2, label=f'Fs2, k = {k}', linestyle='--', color='r', linewidth=1.5)
plt.title(f'Waves for k = {k}', fontsize=14)
plt.xlabel('Time (s)', fontsize=12)
plt.ylabel('Amplitude', fontsize=12)
plt.grid(True)
plt.legend()

plt.tight_layout()
plt.show()

Start coding or generate with AI.

https://colab.research.google.com/drive/1nrWO5UAfOKHw1FD8N4sJMFDhO6OWO2jo#printMode=true 1/2

You might also like