help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rebuild signal from frequency domain to time domain tia sal22


From: Andy Buckle
Subject: Re: rebuild signal from frequency domain to time domain tia sal22
Date: Wed, 9 Mar 2011 11:54:56 +0000

On Wed, Mar 9, 2011 at 11:45 AM, Rick T <address@hidden> wrote:
> rebuild signal from frequency domain to time domain tia sal22
> Greetings all
> I would like to rebuild a signal from the frequency domain
> can this be done using fft?  If so does anyone have some
> example code?
> Here's what I have so far.  I create/import a signal and plot
> using the time domain.  Then I use fft to convert to
> the frequency domain and plot.  What I want to do now is
> be able to convert from the frequency domain data back to the time
> domain.  Then I'll be able to export the file as a wave file
> PS: I won't have an equation to work with because I'll be importing
> an audio file, and I'll be making changes when the signal is
> in the frequency domain.
> But at the moment I'm just trying to convert from the
> frequency domain back to the time domain. So the third plot
> when created would look just like the first plot in the time domain
> in the example below
>
> %time domain
> %create time domain
> Fs = 1000;                    % Sampling frequency
> T = 1/Fs;                     % Sample time
> L = 1000;                     % Length of signal
> t = (0:L-1)*T;                % Time vector
> y = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
> %frequency domain
> NFFT = 2^nextpow2(L); % Next power of 2 from length of y
> Y = fft(y,NFFT)/L;
> f = Fs/2*linspace(0,1,NFFT/2+1);
> subplot(2,1,1),plot(Fs*t(1:50),y(1:50))
> title('Signal ')
> xlabel('time (milliseconds)')
> % Plot  amplitude spectrum.
> subplot(2,1,2),plot(f,2*abs(Y(1:NFFT/2+1)))
> title('Amplitude Spectrum of y(t)')
> xlabel('Frequency (Hz)')
> ylabel('|Y(f)|')
> tia sal22
> --

>y=rand(1,4)
y =

   0.683785   0.772539   0.065463   0.410841

>f=fft(y)
f =

 Columns 1 through 3:

   1.93263 + 0.00000i   0.61832 - 0.36170i  -0.43413 + 0.00000i

 Column 4:

   0.61832 + 0.36170i

>y2=ifft(f)
y2 =

   0.683785   0.772539   0.065463   0.410841

>y-y2
ans =

  0.0000e+000  0.0000e+000  4.1633e-017  5.5511e-017



-- 
/* andy buckle */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]