import numpy as np
# Define the parametersfrequency = 1# Frequency of the waveamplitude = 1# Amplitude of the wavenum_samples = 1000# Number of samples in the wave# Create the quadratic wavet = np.linspace(0, 1, num_samples)
quadratic_wave = amplitude * (4 * (fmod(t, 1 / frequency) * frequency - 0.5)**2 - 1)
# Plot the wave (optional)import matplotlib.pyplot as plt
plt.plot(t, quadratic_wave)
plt.xlabel('Time')
plt.ylabel('Amplitude')
plt.title('Quadratic Waveform')
plt.show()
498 chars
20 lines
This code snippet uses NumPy to create a quadratic wave with a specified frequency and amplitude. The waveform is then plotted using Matplotlib.