Question
how to plot sine wave signal with synchronous and non synchronous sampling in time domain with formula s(t) = A*sin(2*pi*f*t + phi ) the graph must s(t) versus number of cycle? where should i coded the number of cycles?
Expert Answer
John Williams
PhD Expert
Answered Sep 12, 2026
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()
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related sin Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →