| Author |
Message |
aredhel
Joined: 22 Feb 2008 Posts: 36
|
05 Aug 2008 2:07 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:
|
|
| Back to top |
|
 |
gaffar
Joined: 14 Jul 2006 Posts: 71 Helped: 16 Location: Turkey
|
05 Aug 2008 2:16 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.
|
|
| Back to top |
|
 |
aredhel
Joined: 22 Feb 2008 Posts: 36
|
05 Aug 2008 4:39 Re: DSP - Matlab |
|
|
|
| Ok, but I am confused about one thing though, the "sin" ... how is it possible to not have a "j" there?
|
|
| Back to top |
|
 |
xulfee
Joined: 27 May 2008 Posts: 256 Helped: 25 Location: Pakistan
|
05 Aug 2008 5:13 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
|
|
| Back to top |
|
 |
m_pourfathi
Joined: 07 Feb 2008 Posts: 204 Helped: 13
|
05 Aug 2008 5:34 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);
|
|
| Back to top |
|
 |