DSPRelated.com
Forums

DFT and rectangular pulse

Started by fathema_k April 12, 2003
hello there...
i have this Discrete fourier transform function as below and a
function to generate a rectangular wave but the dft function isnt
accepting the rectangular wave as the xn function so as to calculate
its fourier transform....how do i equal the matrix dimension here.
the functions are as follows;

DTFT FUNCTION:
function [y](xn, N)
n=[0:1:N-1];
k=[0:1:N-1];
h=exp((-j*2*pi)/N) ;
nk=n'*(k-1);
hnk=h.^nk;
y=xn*hnk; RECTANGULAR PULSE:

function [y,n]=rect(N, x1)
n=-N/2:N/2;
n1=ones(length(n));
y=x1*n1;
stem(n,y); anybody plz reply asap.
thanx
cheers
Fathema.



Hi

there might be some problem if N is odd. In that case
lenght(n) and N will not be the same. suggestion -
you can use 'fft' command which is already there in
matlab.

--- fathema_k <> wrote:
> hello there...
> i have this Discrete fourier transform function as
> below and a
> function to generate a rectangular wave but the dft
> function isnt
> accepting the rectangular wave as the xn function so
> as to calculate
> its fourier transform....how do i equal the matrix
> dimension here.
> the functions are as follows;
>
> DTFT FUNCTION:
> function [y](xn, N)
> n=[0:1:N-1];
> k=[0:1:N-1];
> h=exp((-j*2*pi)/N) ;
> nk=n'*(k-1);
> hnk=h.^nk;
> y=xn*hnk; > RECTANGULAR PULSE:
>
> function [y,n]=rect(N, x1)
> n=-N/2:N/2;
> n1=ones(length(n));
> y=x1*n1;
> stem(n,y); > anybody plz reply asap.
> thanx
> cheers
> Fathema. >
> ------------------------ Yahoo! Groups Sponsor
>
> _____________________________________
> Note: If you do a simple "reply" with your email
> client, only the author of this message will receive
> your answer. You need to do a "reply all" if you
> want your answer to be distributed to the entire
> group.
>
> _____________________________________
> About this discussion group:
>
> To Join:
>
> To Post:
>
> To Leave:
>
> Archives: http://www.yahoogroups.com/group/matlab
>
> More DSP-Related Groups:
> http://www.dsprelated.com/groups.php3
>
> ">http://docs.yahoo.com/info/terms/


__________________________________________________