I would like to analyze the Fourier Transform of the signal that consists of multiplication of sin and rectangular functions.
I am doing it in the way representing in the code and I would expect to obtain a sinusoidal signal that is "bordered" by the rectangular one. For this purpose, I have selected the period of the rectangular signal equal to T = 0.02s and correspondingly the frequency of the sin signal 1/0.02 = 50 Hz.
The problem is that I obtain an error which forces me to use an elementwise multiplication of the signals (which apparently would not be a correct way).
In the frequency domain I would expect to obtain two sinc-functions that are shifted to the left and to the right by 50Hz/2 (Doppler effect), however the result is a straight line.
What am I doing wrong?
Thank you in advance!
Ts = 0.01; N=2000; t=-20:Ts:(N-1)*Ts;
T = 0.02;
x1 = rectpuls(t, T)*sin(2*pi*1/T*t);
figure(2); plot(f, 1/N*abs(xk(1:length(f))));