Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: DFT
Date: Tue, 3 Nov 2009 21:14:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <hcq6eq$855$1@fred.mathworks.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 1257282842 8357 172.30.248.35 (3 Nov 2009 21:14:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 21:14:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1725513
Xref: news.mathworks.com comp.soft-sys.matlab:582175


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'