Generate single cycle of a sine wave at a particular frequency
89 views (last 30 days)
Show older comments
Hello, I need help generating a single cycle of a sinewave at a particular frequency and sampling rate. The following example generates multiple cycles and I am not sure how to get a single cycle.
fs = 512; % Sampling frequency (samples per second)
dt = 1/fs; % seconds per sample
StopTime = 0.25; % seconds
t = (0:dt:StopTime-dt)'; % seconds
F = 60; % Sine wave frequency (hertz)
data = sin(2*pi*F*t);
Thank you,
4 Comments
KEERTHANA VELUSAMY
on 1 May 2020
Could any one share matlab code for storing the signals data in 2 arrays of 64 elements
Gaurav Wadhai
on 5 Dec 2021
clc;
clear all;
close all;
L = 3; %Up-sampling factor
M = 2; %Down-sampling factor
n = 0:29;
x = sin(2*pi*0.43*n) + sin(2*pi*0.31*n);
y = resample(x,L,M);
subplot(2,1,1),stem(n,x(1:30));
xlabel('Time index n');
ylabel('Amplitude');
title('lnput Sequence');
m = 0:(30*L/M)-1;
subplot(2,1,2),stem(m,y(1:30*L/M));
axis([0 (30*L/M)-1 -2.2 2.21]);
xlabel('Time index n');
ylabel('Amplitude');
title('Output Sequence');
Answers (9)
KSSV
on 27 Oct 2016
fs = 512; % Sampling frequency (samples per second)
dt = 1/fs; % seconds per sample
StopTime = 0.25; % seconds
t = (0:dt:StopTime)'; % seconds
F = 60; % Sine wave frequency (hertz)
data = sin(2*pi*F*t);
plot(t,data)
%%For one cycle get time period
T = 1/F ;
% time step for one time period
tt = 0:dt:T+dt ;
d = sin(2*pi*F*tt) ;
plot(tt,d) ;
2 Comments
anasuya b
on 11 Jan 2018
I wante to make a sine wave . First donot know how to create vector how to create a vector for a sample data of 300 in 5 min time (300 sec) PL help
0 Comments
Fahad Hossen
on 7 Jun 2018
fs = 512; % Sampling frequency (samples per second) dt = 1/fs; % seconds per sample StopTime = 0.25; % seconds t = (0:dt:StopTime)'; % seconds F = 60; % Sine wave frequency (hertz) data = sin(2*pi*F*t); plot(t,data) %% For one cycle get time period T = 1/F ; % time step for one time period tt = 0:dt:T+dt ; d = sin(2*pi*F*tt) ; plot(tt,d) ;
0 Comments
Qammar Taskeen
on 21 Jul 2020
Generate the following signals in MATLAB using subplot command such that the x-axis title contains your UET (2 Fig Roll No.) and y-axis title contains your APCOMS (4 Fig Roll No) while the title of the plot shows your Name and Batch No. (CLO-01, PLO-5) (25 Marks)
- Sinusoid
- Kronecker Delta
- Unit step signal
- Ramp
Complex Exponential
0 Comments
Qammar Taskeen
on 21 Jul 2020
Demonstrate the designing of a circuit in MATLAB Simulink such that it represents the equation sin2 φ + cos2 φ = 1 where φ = UET (2 Fig Roll No.) the output should have an amplitude of 1 on the “scope”. Save the .mdl file and attach it in the online submission of this assignment. Also add its screenshot in the assignment.
0 Comments
Qammar Taskeen
on 21 Jul 2020
Demonstrate the generation of a Saw Tooth wave from its Fourier Series in MATLAB such that the x-axis title contains your UET (2 Fig Roll No.) and y-axis title contains your APCOMS (4 Fig Roll No) while the title of the plot shows your Name and Batch No.
0 Comments
Qammar Taskeen
on 21 Jul 2020
Find and Demonstrate the inverse Z-Transform of following. Here a and b are the two digits of your UET (2 Fig Roll No.) whereas c, d, e and f represent the 4-digits of your APCOMS (4 Fig Roll No).
0 Comments
Sanjay Talbar
on 6 Jul 2021
fs = 512; % Sampling frequency (samples per second)
dt = 1/fs; % seconds per sample
StopTime = 0.25; % seconds
t = (0:dt:StopTime-dt)'; % seconds
F = 60; % Sine wave frequency (hertz)
data = sin(2*pi*F*t);
0 Comments
HARSH VARDHAN
on 22 Jan 2024
Q1. Write A Matlab code
a) To Generate the following frequency signals and play as audio tones for each one second duration.
Sa
Re
Ga
Ma
Pa
Da
Ni
Sa
240Hz
270Hz
300Hz
320
360Hz
400Hz
450Hz
480Hz
b) To Create a variable to store the following tune and also play the audio tone for following sequences : Sa Re Sa Re| Sa Re Ga Ma| Sa Ni Sa NI |Sa Ni Da Pa
c) Also show the amplification and attenuation of the above generated tone
Q2. Write a Matlab code
a) to read the given input signal data from Microsoft Excel sheet and store the same.
b) to display the graph of above stored date.
c) to perform the following signal operations on the input signal
i. x(2t-1)
ii. 2*x(4+t)
iii. x(2-0.5t)
iv. (2/3)*x(2+0.5t)
0 Comments
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!