How to write a matlab code to calculate the discrete fourier series

Status
Not open for further replies.

aredhel

Member level 2
Joined
Feb 22, 2008
Messages
50
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Visit site
Activity points
1,800
DSP - Matlab

Hello there, anyone knows how to write a matlab code to calculate the discrete fourier series and its inverse given by:



and then verify the code for the following input sequence:

 

Re: DSP - Matlab

First you have to give the range of n:

n=first:last;

then you can use N-point dft function for MATLAB:

X=fft(x,N);

where fft is "fast fourier transform", and you can find details about it on MATLAB help.
 

Re: DSP - Matlab

Ok, but I am confused about one thing though, the "sin" ... how is it possible to not have a "j" there?
 

DSP - Matlab

j is available there in matlab,what confusion u've in it,don't use fft bcoz it finds fast fouirer transform,where u wrote equations to find out fourier co-effients,just rite code like C
 

Re: DSP - Matlab

you need to create a numerical sequence of x[n] in one period. For example you need n to be 0<n<N. Here's what you do:

% N is the period of the x[n] sequence.
n = 0:N;
x = 1 + sin(n*pi/4) + 2*cos(n*pi/2);
X = fft(x,N);
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…