I know this is an old thread but I thought I'd reply to it as I'm essentially using the script posted here. Here is the script that I've got just now:
close all N = 101; t=[-0.1:0.002:0.1]; x=(1-2.*pi^2.*20^2.*t.^2).*exp(-pi^2.*20^2.*t.^2); % Produce Ricker wavelet X=fft(x); p = 2; % Fraction of a time period to shift data Y=exp(1i*2*pi*p*((0:N-1)-N/2)/N); % Conjugate-Symmetric shift Z=X.*Y; % Apply the shift z=ifft(Z); % Back into the time domain - should be real (more or less) z=real(z); figure plot(t,x,'b',t,z,'r') % Plot original and shifted wavelet figure f=[0:1:100]; f=f*(500/2)/(101/2); % Create frequency range for plotting plot(f,abs(X),'b',f,abs(Z),'-.r') % Plot frequency spectra axis([0 250 0 12]) % Limit axis range to Nyquist frequency figure plot(f,angle(X),'b',f,angle(Z),'-.r') % Plot phase spectra axis([0 250 -4 4])
What I'm trying to do here is produce a 20 Hz Ricker wavelet, phase shift it by 360 degrees then plot the original and shifted wave followed by their frequency and phase spectra. The problem I'm having is that when I plot the shifted wavelet, the whole wavelet has moved by two samples and I don't know why. If I replace line 3 (and make other changes where appropriate) with "t=[-0.1:(0.2/1023):0.1];" this shift disappears but the frequency spectra of the two wavelets no longer looks right. I've tried padding my original t out with 0s to 1024 but that doesn't help.