From: Chris on 11 Feb 2010 16:51 "John " <jwu0823(a)hotmail.com> wrote in message <gli8kk$ltk$1(a)fred.mathworks.com>... > I got it! The biggest mistake I made was that I made f fixed and mixed up with the sampling frequency. > Thanks for all the help, especially to Greg. I'm trying to get the same thing working and am having problems too. clear all Fs = 100; dt = 1/Fs; t0 = pi/2; t = 0:dt:3*pi; l = max(size(t)); df = 1/dt;%dt*2*pi; dw = 2*pi*df; f = (-1*length(t)/2:1:length(t)/2-1)*df; f = fftshift(f); w = 2*pi*f; w = fftshift(w); x = sin(t); x2 = sin(t-t0); X = fft(x); X = X.*exp(-i*2*pi*t0*f/length(t)); y = ifft(X); plot(t,x) hold on plot(t,x2,'r--') plot(t,y,'g') is my code and what should be happening is that the output y should matchup with the x2 however, there is some rectification as well as attenuation going on. any ideas?
From: Matt J on 16 Feb 2010 23:25 "Chris " <news(a)comcast.com> wrote in message <hl1u46$cib$1(a)fred.mathworks.com>... > "John " <jwu0823(a)hotmail.com> wrote in message <gli8kk$ltk$1(a)fred.mathworks.com>... > > I got it! The biggest mistake I made was that I made f fixed and mixed up with the sampling frequency. > > Thanks for all the help, especially to Greg. > > I'm trying to get the same thing working and am having problems too. ==================== I hope this is homework, rather than an actual application. Time shifting using FFTs is super-inefficient.
From: Greg Heath on 16 Feb 2010 19:31 On Feb 11, 4:51 pm, "Chris " <n...(a)comcast.com> wrote: > "John " <jwu0...(a)hotmail.com> wrote in message <gli8kk$lt...(a)fred.mathworks.com>... > > I got it! The biggest mistake I made was that I > made f fixed and mixed up with the sampling frequency. > > Thanks for all the help, especially toGreg. > > I'm trying to get the same thing working and am having > problems too. > > clear all > > Fs = 100; > dt = 1/Fs; > t0 = pi/2; > > t = 0:dt:3*pi; t = dt*(0:N-1) = 0:dt:T-dt % T = N*dt > l = max(size(t)); > df = 1/dt;%dt*2*pi; No. See above that Fs = 1/dt df = 1/T = 1/(N*dt) > dw = 2*pi*df; > f = (-1*length(t)/2:1:length(t)/2-1)*df; > f = fftshift(f); No. fftshift is only used on transforms > w = 2*pi*f; > w = fftshift(w); No. fftshift is only used on transforms > x = sin(t); > x2 = sin(t-t0); > > X = fft(x); > X = X.*exp(-i*2*pi*t0*f/length(t)); > y = ifft(X); > > plot(t,x) > hold on > plot(t,x2,'r--') > plot(t,y,'g') > > is my code and what should be happening is that the output y should matchup with the x2 however, there is some rectification as well as attenuation going on. any ideas? See my post. Hope this helps. Greg
From: Chris on 17 Feb 2010 10:25 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hlfr3a$97g$1(a)fred.mathworks.com>... > "Chris " <news(a)comcast.com> wrote in message <hl1u46$cib$1(a)fred.mathworks.com>... > > "John " <jwu0823(a)hotmail.com> wrote in message <gli8kk$ltk$1(a)fred.mathworks.com>... > > > I got it! The biggest mistake I made was that I made f fixed and mixed up with the sampling frequency. > > > Thanks for all the help, especially to Greg. > > > > I'm trying to get the same thing working and am having problems too. > ==================== > > I hope this is homework, rather than an actual application. Time shifting using FFTs is super-inefficient. How would you suggest to time shift then.
From: Matt J on 17 Feb 2010 11:04 "Chris " <news(a)comcast.com> wrote in message <hlh1on$mq$1(a)fred.mathworks.com>... > "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hlfr3a$97g$1(a)fred.mathworks.com>... > > "Chris " <news(a)comcast.com> wrote in message <hl1u46$cib$1(a)fred.mathworks.com>... > > How would 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.
|
Next
|
Last
Pages: 1 2 Prev: MEX Setup for Mac OS X 10.6 Next: execute a matlab script from a web page |