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.

Problems with fft and ifft

Status
Not open for further replies.

lionelgreenstreet

Junior Member level 3
Joined
Sep 25, 2008
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,503
I have some problems with this script written i mat alab...
1) i make a sampled sinusoidal waveform (with sampled frequency greather then twice sinusoidal frequency), then use fft command
2)cut values obtained at frequency greather then nyquist frequency (i want simulate an ideal low-pass filter
3)ifft
I shoud obtain the same waveform, but i obtain a waveform not distorted, with the same frequency, but not the same amplitude...Whai is the problem?
This is the code

%samplign period
Ts =0.0001;
Fs=1/Ts;
%signal period
T=1;
%number of samples
N=T/Ts;
%time
t = (0:N-1)*Ts;
signal=sin(2*pi*10*t);
%fft
SIGNAL = fft(signal);
freq=(0:length(t)-1);
%Ifft
%cutoff frequency
cutoff=100;
SIGNALFILTERED=padarray((SIGNAL(1:cutoff)),[0 N-cutoff],'post');
anti=real(ifft(SIGNALFILTERED));
anti2=real(ifft(fft(signal)));
figure(1)
plot(t,anti);hold on;
plot(t,anti2,'r');
hold off;

Thanks n advance
 

Remember that the output of a complex FFT contains both positive and negative halves of the spectrum. You've zeroed-out too much, and lost the entire negative frequency half of the spectrum (and the negative frequency half of your signal). Try zeroing from index 101 through 9901 instead of from 101 through 10000.

I didn't know about the 'hold' command. Thanks!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top