Expert Answer
John Williams answered .
2025-11-20
I can asnwer this in python and you can convert it in matlab
Please check the python code:
Import the necessary libraries:
import numpy as np
import matplotlib.pyplot as plt
Define the parameters of your sine wave signal, including amplitude (A), frequency (f), phase (phi), and the sampling rate (Fs).
A = 1.0 # Amplitude of the sine wave
f = 5.0 # Frequency of the sine wave (in Hz)
phi = 0.0 # Phase of the sine wave (in radians)
Fs_sync = 50.0 # Synchronous sampling rate (samples per second)
Fs_non_sync = 10.0 # Non-synchronous sampling rate (samples per second)
Define the time vector for both synchronous and non-synchronous sampling. The number of cycles should be specified here.
# Number of cycles for the signal
num_cycles = 5
# Time vector for synchronous sampling
t_sync = np.arange(0, num_cycles * 1 / f, 1 / Fs_sync)
# Time vector for non-synchronous sampling
t_non_sync = np.arange(0, num_cycles * 1 / f, 1 / Fs_non_sync)
Calculate the sine wave signal for both sampling rates:
# Calculate the synchronous sine wave
s_sync = A * np.sin(2 * np.pi * f * t_sync + phi)
# Calculate the non-synchronous sine wave
s_non_sync = A * np.sin(2 * np.pi * f * t_non_sync + phi)
Plot the results using Matplotlib:
# Plot the synchronous sampled signal
plt.figure(figsize=(12, 6))
plt.subplot(2, 1, 1)
plt.plot(t_sync, s_sync)
plt.title('Synchronous Sampling')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.grid()
# Plot the non-synchronous sampled signal
plt.subplot(2, 1, 2)
plt.plot(t_non_sync, s_non_sync)
plt.title('Non-Synchronous Sampling')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.grid()
plt.tight_layout()
plt.show()
Not satisfied with the answer ?? ASK NOW