From: Shaddy on 16 Nov 2009 13:22 I am trying to write a simple example to test the time shift property of FFT. I have two problems which I hope that someone can help me with. Here is the program I wrote: close all; clc; clear all; T=1; %% period A=1; %% Amp. N=2^15; %% number of points w=2*pi/T; t0=.4; %% Time Shift t=linspace(0,2*T,N); dt=t(2)-t(1); Fs=1/dt; %% Sampling frequency f = Fs*linspace(0,1,N); y1=A*sin(w*t); %original function in time Y1=fft(y1); %convert to Freq domain y1shifted=ifft(Y1.*exp(-2*pi*i*t0*f)); % Linear phase shift in %%freq domain convert back to time domain figure; subplot(2,1,1) plot(t,y1,'b') grid on xlim([min(t) max(t)]) ylim([-A A]) title('Original Function sin(t)'); ylabel('t') subplot(2,1,2) plot(t,y1shifted,'r') grid on xlim([min(t) max(t)]) ylim([-A A]) title('Shifted Function sin(t-t_0)'); ylabel('t') 1) I keep getting the following error msg,: 'Warning: Imaginary parts of complex X and/or Y arguments ignored' and the plot does not look as I may expect it to be. When I replace the linear phase shift in freq domain and converting back to time domain to : y1shifted=ifft(Y1.*exp(-2*pi*i*t0*f),'symmetric'); % Linear phase shift in %%freq domain convert back to time domain Can someone explain to me why is that? 2) When I change the t to t=linspace(0,2.3*T,N); I gets a weird behavior at the beginning of the pot. Why? Thank you
|
Pages: 1 Prev: Can we convert simulink *.mdl file to matlab *.m file Next: "simultaneous" fit? |