"BC Tan" <rainzz@live.com> wrote in message <h6ot9q$1gu$1@fred.mathworks.com>...
> Hi All,
>
> I am new to matlab. I had the following 10 point sequence y(n) = { 1, 2, 3, 4, 5, 5, 4, 3, 2, 1].
>
> a) I would like to determine the DFT Y(k) of y(n) and plot (using stem function) its magnitude and phase.
>
> b) i would like to determine the DTFT of y(n) and plot the magnitude and phase. (plus i would like to know how can i properly define the resolution of the DTFT in the frequency domain.
>
> Can anyone advise me or provide me with an example?
>
> Thanks
To plot the magnitude for dft_vector using stem function you have a detailed example here:
http://www.bearcave.com/misl/misl_tech/signal/dftwin/index.html
Also here is a source to compute the dft and plot magnitude for a triangular window. You can adapt the code to your needs.
http://matlabdb.mathematik.unistuttgart.de/download.jsp?MC_ID=3&MP_ID=356
Also you cand plot your magnitude and find your phase by looking here:
DFT is defined as X(k)= summation from n=0 to N1 of Ej*2*pi*k*(n/N)
% program to find Npoint DFT of a given function x(n) and also its IDFT
clear all ; % close all
x=input('enter the sequence ');
N=input('Enter the length of the DFT');
xk=fft(x, N); %find DFT
magnitude=abs(xk); %find magnitude
subplot(2,2,1);
n=0:N1;
stem(n,magnitude); % plot magnitude response.
phaseplot=angle(xk); %find phase angle
subplot(2,2,2);
stem(n,phaseplot); %plot phaseplot
%To find IDFT
xn=ifft(xk); %find IDFT
subplot(2,2,3);
stem(xn); %plot IDFT sequence
I think it's exactly what you need!
Best wishes,
Michael
