Monday, 4 June 2012

On 14:13 by Unknown in    1 comment
 Signals, FFT & IFFT

In Matlab we can draw different types of signal. Also do different operations on that signal in time, frequency, and Z domains. This is the beauty of DSP that we work o signals in frequency domain and then go back to Time domain easily.  Here in this post I will discuss to draw different signals in Time Domain and then go to Frequency domain, do some changes in Frequency domain, then go back to Time domain and see changes which was done in Time domain. 


n=0:1:1024;                                            % Define the time interval 
w1 = 0.1 * pi;                                          % Define the Omega (w) values for cosine signals
w2 = 0.2 * pi;
w3 = 0.4 * pi;
xn = sin(w1*n) + sin(w2*n) + sin (w3*n);        % Signal is a Composite signal
figure (1)
subplot(3,1,1);
plot(n,xn);
title('Original Signal X[n]');
xf = fft(xn);                                          % fft Command is used to convert to Frequency Domain
subplot(3,1,2); 
plot(n,xf);
title('X(e^jw))');
xmag = abs(xf);                                      % Magnitude of fft Signal
subplot(3,1,3); 
plot(n,xmag);
title('Magnitude of X(e^jw))');
x = sin(w3*n);                                        % 2nd Signal in Time Domain 
x_fft = fft(x);                                       % fft of 2nd Signal

xf = xf - x_fft;                                         % Subtract 2nd Signal from Original Signal in Frequency Domain                                                
xnt=ifft(real(xf));                                         % Convert Back Modified F_domain Signal to Time domain
figure (2)
plot (n,xnt);
title('Back to Time Domain & see the changes');
a) Time Domain, b) Frequency Domain, c) Magnitude in Frequency Domain 

Reverse Signal in Time Domain From Frequency Domain

1 comment: