Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: how do I correctly apply a phase shift to a waveform?
Replies: 2   Last Post: May 1, 2013 7:01 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Daniel

Posts: 1
Registered: 5/1/13
Re: how do I correctly apply a phase shift to a waveform?
Posted: May 1, 2013 7:01 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.

Thanks in advance for the help.

Daniel



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.