Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Not getting the same signal after FFT and IFFT in Matlab

Status
Not open for further replies.

badash_123

Junior Member level 2
Joined
May 13, 2009
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,461
Hi

I have a signal that I perform FFT on. When I perform IFFT on the FFTed signal I dont get back the old signal. Where am I wrong?

My signal is waveform2. I used FFT and IFFT as:

fftvalue= abs(fft(waveform2));
ifftvalue=real(ifft(fftvalue));

Ifftvalue and waveform2 are not same. Is it supposed to be like that or Am i missing something here? Please help. Thanks.
 

you are making the following transformation:
Code:
ifft(abs(fft(waveform2)))
instead of:
Code:
ifft(fft(waveform2))
The abs function changes the fft of waveform2...
 
Thank you.

The waveform2 is in time domain and I need some information about the waveform2 like contributing factors at certain frequencies. Once obtaining the info, i would need to allow only certain frequencies. I think I can do that using band pass filters. But How do I get to know about the frequencies? Do I not need the abs along with fft? I cannot know anything from using fft(waveform2). Can you help me with this? Thanks
 

The FFT is a series of complex numbers and it absolute value is only part of the information.
You ca look at the abs(fft(x)) but do your filtering on fft(x) only...
How do you know what frequencies you want to pass?

I believe you need to give more details about your problem to allow the people in this forum to help you.
 

Ok.

I have a waveform obtained from an FPGA performing an encryption algorithm. I need to find out some info (secret key) of the algorithm by analyzing the waveform that I get. The waveform is in time domain. I do not know anything from time domain. So I intend to change it to frequency spectrum so that I ll know at certain frequencies (clock frequency of FPGA - 50Mhz, Multiples of clock frequency of FPGA) what operation it should be doing.

I want to analyze the waveform at say 50 to 150 Mhz instead of the entire freq spectrum which may add unwanted noise. For this I wanted to use band pass filtering.

So 1) I should convert my time domain signal to freq domain with the x axis to be in freq. For that just fft(waveform) doesn help me. What should I do for that?

2) Once I get the waveform in freq spectrum, I need only 50 Mhz to 150 Mhz signal components. So I would need band pass filter. On which signal do I need bpfilter on? fft(x) or....?

3) I have posted a question already in another thread asking about filtering in matlab. I can use fdesign.bandpass or fdatool and get the co-efficients of the filter. But how do I give my waveform as its input? Is it correct to use filter(b,1,waveform) b here being the co efficients of the filter i generate using fdatool?

Hope this gives you some idea about my doubts. Thanks
 

If your sampling frequency is 50MHz, the FFT will only show frequencies between 0 and 25MHz. The higher frequencies will fold back to this frequency range. The frequency range you are interested in (50MHz to 150MHz) cannot be represented by the FFT and your sampled signal cannot be filtered.
If you want to see what happens between 50MHz and 150MHz you need to sample the signal with a sampling clock higher than 300MHz.
 

Thanks. I am using 1Ghz samples per period. I used semilogy plot with freq and power of the signal and I think I am seeing components from 0 to 500 Mhz with this. Now I want to use only 0 to around 150 Mhz of this waveform. As I said earlier I used fdatool to get the specfications of the filter with pass band 50 to 150 Mhz. I need to know how I could make it perform filtering on my waveform.

The generated M file is:

function Hd = bp50to150M
%BP50TO150M Returns a discrete-time filter object.

%
% M-File generated by MATLAB(R) 7.9 and the Signal Processing Toolbox 6.12.
%
% Generated on: 08-Dec-2010 00:00:11
%

% Equiripple Bandpass filter designed using the FIRPM function.

% All frequency values are in MHz.
Fs = 1000; % Sampling Frequency

Fstop1 = 45; % First Stopband Frequency
Fpass1 = 50; % First Passband Frequency
Fpass2 = 150; % Second Passband Frequency
Fstop2 = 155; % Second Stopband Frequency
Dstop1 = 1e-005; % First Stopband Attenuation
Dpass = 0.057501127785; % Passband Ripple
Dstop2 = 1e-005; % Second Stopband Attenuation
dens = 20; % Density Factor

% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fstop1 Fpass1 Fpass2 Fstop2]/(Fs/2), [0 1 ...
0], [Dstop1 Dpass Dstop2]);

% Calculate the coefficients using the FIRPM function.
b = firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);

I need to multiply the waveform and the freq response right? Or is there any other method to do filtering?

The fft prog that I used is:

N = 50000; %% number of points
T = N/(10^9);
p = abs(fft(f)); %% absolute value of the fft
% p = p(1:N/2).^2 %% take the power of positve freq. half
% freq = [0:N/2-1]/T;
% semilogy(freq,p);

Please tell me if there is anything wrong in what I have tried. Thanks.
 

I do not have matlab with me at this moment and cannot check your code but at a first look your code is correct. Now that you have the filter coefficients, you can use the "filter" function. This function just needs the filter coefficients and the signal in time domain, the output will be your bandpass-ed signal (try the fft before and after "filter").
 

I think I get what you are saying. I will try this and get back to you again tomorrow. Thanks.
 

Thanks JoannesPaulus. It seems to be doing what I wanted.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top