Im trying to generate a sweep sine wave that increases its frequency till an upper limit and then starts decreasing its frequency to the lower limit at the same rate. Im trying to simulate in matlab.
The frequency of the wave will change based on the following formula: f = fmax-a*abs(T - t); a in the formula equals (fmax-fmin)/T So the frequency should first increase and then decrease after it reaches time T at the same rate.
The matlab code is:
freq1 = 20; freq2 = 200; fs = 44100; endTime = 0.1; t = 1/fs:1/fs:(endTime*2); a = (freq2-freq1)/endTime; f = freq2 - a*abs(endTime - t); sinwave = sin(2*pi*f.*t); plot(t,sinwave)
It seems to display a very different result when we plot the value obtained. After T the plot suddenly reverses, changes to original value of frequency and again increases in frequency I am not able to understand this behavior as the frequency seems to give values that increase and then decreases. Please help me understand why the plot for waves shows a different value and how to correct this. (Sorry not able to include plot due to web site restrictions)