MATLAB: How to create sine wave with varying amplitude between certain range

MATLABsine wavevarying amplitude

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?

Best Answer

%if
amp = 1:2:5;
data = amp.*abs(sin(2*pi*F*t))
Use abs to plot only the fixed amplitude range