How can I create sine wave with varying amplitude between certain range?
47 views (last 30 days)
Show older comments
I am trying to create a sine wave with varying amplitude. I am using a function for amplitude i.e., sqrt(t) where t is the time stamps. This is creating a sine wave with smoothly increasing amplitude. But I want amplitude to vary between certain range keeping the frequency same. For example, between 1 and 5. Below is the code which I wrote.
fs = 2560; % Sampling frequency
dt = 1/fs; % seconds per sample
StopTime = 5; % seconds
t = (0:dt:StopTime)'; % seconds
F = 20; % Sine wave frequency (hertz)
amp = sqrt(t);
data = amp.*sin(2*pi*F*t);
figure(1);clf(1);
plot(t,data);
title('Sine Wave');
What should be the function of amplitude in order to achieve varying amplitude?
3 Comments
RAHUL DOGRA
on 22 Nov 2021
I want an increased sine function than make it constant after some particular value how can I do that?
Accepted Answer
VBBV
on 9 Dec 2020
%if
amp = 1:2:5;
data = amp.*abs(sin(2*pi*F*t))
Use abs to plot only the fixed amplitude range
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!