I'm trying to create real signals like a sine wave or a sine sweep in MATLAB. Since I want to go deep into the theory of the discrete Fourier transform, I'm trying to create those signals through defining a vector for my frequency response and the associated phase response in the frequency domain, to retrieve the corresponding signal in time domain using a 1000 point ifft
function of MATLAB. The problem is, I just can't get the phase responses right.
fa=16000;
n=1000;
t=(0:(n-1))/fa;
f=(0:(n-1))*fa/n;
%% sine
% frequency response
X=zeros(1,1000);
X(26)=1;
% Phase
ANG=exp(-1i*pi/2);
X=X.*ANG
X=[X(1:501) conj(fliplr(X(2:500)))];
figure;
plot(f,real(X));
x=ifft(X);
figure
stem(x);
%% Sweep
% amplitude
SWEEP_real=ones(1,1000);
%Phase
for n=1:1000
ANG=exp(-1i*(pi/2)/(1000-n));
n=n+1;
end
SWEEP=SWEEP_real*ANG;
sweep=ifft(SWEEP);
figure
stem(sweep)
For the sine wave it somehow works, even though the phase response isn't right. I know what those phase responses should look like, but I just can't recreate them. Any tips or suggestions how to recreate those phase responses would be appreciated. Maybe I'm not approaching this task right, I'm just very confused...