From: Matt J on 17 Feb 2010 11:44 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hlh41o$sjs$1(a)fred.mathworks.com>... you suggest to time shift then. > > interp1(t,x,t+t0) > > This is an O(N) computation using only real arithmetic, whereas with FFTs it's > an O(N*logN) computation using complex arithmetic. Actually, interp1() has a lot of overhead in it, because it has to handle non-uniform spacing as well as a lot of extra functionality. I would recommend conv() instead. To give you an idea of the difference, the following compares, roughly, the operations in a t0=0.5 shift using the two methods: N=1e6; dt=1; fAxis=ifftshift((0:N-1) -ceil((N-1)/2))/N/dt; y=rand(1,N); t0=.5; tic; z=ifft(fft(y).*exp(-j*2*pi*t0*fAxis)); toc; %Elapsed time is 0.283069 seconds. clear z; tic; z=(conv(y,[t0,1-t0])); toc; %Elapsed time is 0.032134 seconds.
First
|
Prev
|
Pages: 1 2 Prev: MEX Setup for Mac OS X 10.6 Next: execute a matlab script from a web page |