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.

Kindly help for FFT. It is giving peak very high in matlab

Status
Not open for further replies.

moonnightingale

Full Member level 6
Joined
Sep 17, 2009
Messages
362
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Activity points
3,832
I got this code for fft but it is giving very high peak at 500.
If u take actaul fourier of COS peak is low. Plz help me to remove this problem.
I will be highly grateful for this.

Actually i want to represent the signal in frequency domain. somebody told me FFT can be used for this in MAtlab. Is there other way of doing so.


%Define number of samples to take
number_of_samples = 2^10;
cosineFreq = 10; %Hz

%Define signal
t = linspace(0, 10, number_of_samples);
signal = cos(2*pi*cosineFreq*t);

%Plot to illustrate that it is a sine wave
plot(t, signal);
title('Time-Domain signal');

%Take fourier transform
fftSignal = fft(signal);

%apply fftshift to put it in the form we are used to (see documentation)
fftSignal = fftshift(fftSignal)

%Next, calculate the frequency axis, which is defined by the sampling rate
T = t(2)-t(1);
fs = 1/T;
f = fs/2*linspace(-1,1,number_of_samples);

%Since the signal is complex, we need to plot the magnitude to get it to
%look right, so we use abs (absolute value)
figure
plot(f, abs(fftSignal));
title('magnitude FFT of cosine');
xlabel('Frequency (Hz)');
ylabel('magnitude');
 

There is nothing wrong with your FFT. You only need to scale the output:
fftSignal = fft(signal)/(2/number_of_samples);

Added after 1 minutes:

Ooops, I mean:
fftSignal = fft(signal)/(number_of_samples/2);
 

Re: Kindly help for FFT. It is giving peak very high in mat

What other say
Can anybody tell me actual FFT of Cosine
I think it is having pi function in it.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top