From: omegayen on 1 Jun 2010 18:37 Hi, I am trying to determine a simple way to convert a periodic function which is a product of bessel and cosine functions to a phase shifted version of that function. I have the sampled versions of these functions but dont know how to compute an easy function as a relationship that allows one to go between the two. These functions occur at the same frequency and just plotting them one can see all that is different is the functions are phase shifted. I posted an example of what it looks like at http://drop.io/omegayen/asset/phase-shift-621-jpg the red stars in my opinion are simply the original blue x's shifted I have seen in other posts the recommendation of using xcorr of the two functions and then looking at the maximum value xcorr which gives the phase shift. I don't really understand this though, my idea of phase shift was converting to the frequency domain and using the time shift property, as an example of this fs=50; %50 Hz sampling frequency T=1/fs; % sampling interval N_0 = 100; %100 points sampled at n=(0:N_0-1); % n= 0, 1 ,2 ,3 ..., N_0 - 1 r=n; % by defintion r= 0, 1 ,2 ,3 ..., N_0 - 1 x=T*cos(2*pi*10*n*T); %cosine wave at 10 Hz in time domain delay=3; y=T*cos(2*pi*10*(n-delay)*T); %cosine wave at 10 Hz in time domain plot(x,'-.x') hold on; plot(y,'-.*r') hold off; phaseshift = exp(-1j*r*((2*pi)/N_0)*delay); X=fft(x); %take the fourier transform of x to get X Y1=X.*phaseshift; y1 = ifft(Y1,'symmetric'); figure, plot(y,'-.*r') hold on plot(y1,'-.ob') hold off; However with the frequency domain method one needs to know the period and the number of samples in each period is there a way one can eyeball the period and number of samples from the graph or a better way to calculate in matlab now when I compute max(xcorr(x,y)) ans = 0.019561803398875 thanks for any help you can provide
|
Pages: 1 Prev: Serial port interrupt in Gui. Next: Dicomread changes pixel values! |