Find the 5-point DFT of the sequence:
6 views (last 30 days)
Show older comments
Good day.
I'm trying to code the 5-point DFT of the following sequence:
u = {sinj} between the limits 4 & j=4
The answer I'm looking for is:
(1/2i) 1-e^5i/1 - e^i - (1/2i) 1-e^-5i/1 - e^-i
This is the code I have thus far:
syms u
u = sin(j);
u = sin(j) * exp((-2*pi*i*j*k)/5);
symsum(u, 0, 5)
Giving me the result:
sin(1) + sin(exp(-2*i*j*k)) + sin(exp(-(2*i*j*k)/5)) + sin(exp(-(4*i*j*k)/5)) + sin(exp(-(6*i*j*k)/5)) + sin(exp(-(8*i*j*k)/5))
Not sure where I'm making my error or if my code is just completely wrong.
Thank you in advance.
Regards
Ruwan
2 Comments
Paul
on 8 Apr 2021
Presumably the sequence is x[j] = sin(j) for j = 0 to 4?
By definition the 5-point DFT of x[j] is a 5-point sequence. But the question says the answer is supposed to be a single value. Is that value supposed to be just one point in the DFT sequence?
The symsum is going over 0-5, which is 6 points.
Can you clarify your question?
Accepted Answer
Paul
on 8 Apr 2021
Edited: Paul
on 8 Apr 2021
The code posted has a few issues.
The second line is:
>> u = sin(j)
u =
0.0000e+00 + 1.1752e+00i
>> whos u
Name Size Bytes Class Attributes
u 1x1 16 double complex
Unless otherwise defined, Matlab treats j as sqrt(-1). So if you haven't declared j as a sym object (or assigned it some other value), the variable u is becomes a double with value u = sin(sqrt(-1)).
The summation in this line:
symsum(u, 0, 5)
should be from 0 to 4, which is five points. Also, it's safer to be unambiguous about the variable to sum over. Also, the code is using i, which also is equal to sqrt(-1) unless otherwise defined, but it's better to use 1i, which is unambiguous. So the corrected code should be
>> syms j k real
>> U(k) = symsum(sin(j)*exp(-2*pi*1i*j*k/5),j,0,4); % five point DFT of sin(j)
>> U(k)
ans =
exp(-(pi*k*2i)/5)*sin(1) + exp(-(pi*k*4i)/5)*sin(2) + exp(-(pi*k*6i)/5)*sin(3) + exp(-(pi*k*8i)/5)*sin(4)
Verify this answer:
>> vpa(norm((U(0:4))-fft(sin(0:4))))
ans =
0.0000000000000001690981417154962344172159894936
It may be possible to simplifty the form of U(k).
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!