Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: DFT
Date: Tue, 3 Nov 2009 22:08:00 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 35
Message-ID: <hcq9k0$pk1$1@fred.mathworks.com>
References: <hcq6eq$855$1@fred.mathworks.com> <26b9039c-8b85-4c0b-b0de-f5050f962223@f18g2000prf.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257286080 26241 172.30.248.35 (3 Nov 2009 22:08:00 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 22:08:00 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1725513
Xref: news.mathworks.com comp.soft-sys.matlab:582190


Thank you for the reply but I am still getting the same error after making the summation limits as k-1 and n-1.I have to get a DFT plot which is a combination of sine waves.Pls help
Thanx.

TideMan <mulgor@gmail.com> wrote in message <26b9039c-8b85-4c0b-b0de-f5050f962223@f18g2000prf.googlegroups.com>...
> On Nov 4, 10:14?am, "Madhumitha Iyer" <pyarsa_ma...@yahoo.co.in>
> wrote:
> > x=[zeros(1,10),ones(1,15),zeros(1,10)]; ? ?%square wave generator
> > %The total number of samples are 10+15+10=35
> > figure(1)
> > subplot(2,1,1)
> > plot(x)
> > N=35;
> > for k=0:N-1
> > ? ? for n=0:N-1
> > ? ? ? ? x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));
> > ? ? ? ? subplot(2,1,2)
> > plot(x(k))
> > ? ? end
> > end
> >
> > The above code is for finding the DFT coefficients.I am getting the following error while running this program:
> >
> > "Subscript indices must either be real positive integers or logicals."
> >
> > Error in ==> DSPnov3 at 9
> > ? ? ? ? x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));
> > Pls tell me how I can rectify the error.I am writing the code for finding DFTs without using the matlab command 'fft'
> 
> Well, the error message says it all really:
> "Subscript indices must either be real positive integers or logicals."
> 
> In other words, you cannot have zero as an index into a vector as you
> have done.
> You need to start at 1, not zero.
> Then, in your summation you must use n-1 and k-1