Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!k13g2000prh.googlegroups.com!not-for-mail
From: TideMan <mulgor@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: DFT
Date: Tue, 3 Nov 2009 15:50:13 -0800 (PST)
Organization: http://groups.google.com
Lines: 51
Message-ID: <d74f6396-7ea0-413d-9349-15abf41bbf5e@k13g2000prh.googlegroups.com>
References: <hcq6eq$855$1@fred.mathworks.com> <26b9039c-8b85-4c0b-b0de-f5050f962223@f18g2000prf.googlegroups.com> 
	<hcq9k0$pk1$1@fred.mathworks.com>
NNTP-Posting-Host: 202.78.152.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1257292213 22506 127.0.0.1 (3 Nov 2009 23:50:13 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 3 Nov 2009 23:50:13 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: k13g2000prh.googlegroups.com; posting-host=202.78.152.105; 
	posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
User-Agent: G2/1.0
X-HTTP-Via: 1.1 bc3
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.4) 
	Gecko/20091016 Firefox/3.5.4,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:582211


On Nov 4, 11:08 am, "Madhumitha Iyer" <pyarsa_ma...@yahoo.co.in>
wrote:
> 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 <mul...@gmail.com> wrote in message <26b9039c-8b85-4c0b-b0de-f5050f962...@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

No, No, No, No!!
I guess you have a problem listening.
Matlab has told you and I have re-iterated that you cannot have zero
as an index.  Yet you persist.
It will only work when you pay attention to what Matlab is telling
you.
Start your bloody loops with 1, not zero!