<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264879</link>
    <title>MATLAB Central Newsreader - DFT</title>
    <description>Feed for thread: DFT</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 03 Nov 2009 21:14:02 -0500</pubDate>
      <title>DFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264879#691845</link>
      <author>Madhumitha Iyer</author>
      <description>x=[zeros(1,10),ones(1,15),zeros(1,10)];    %square wave generator&lt;br&gt;
%The total number of samples are 10+15+10=35&lt;br&gt;
figure(1)&lt;br&gt;
subplot(2,1,1)&lt;br&gt;
plot(x)&lt;br&gt;
N=35;&lt;br&gt;
for k=0:N-1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for n=0:N-1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;subplot(2,1,2)&lt;br&gt;
plot(x(k))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
The above code is for finding the DFT coefficients.I am getting the following error while running this program:&lt;br&gt;
&lt;br&gt;
&quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; DSPnov3 at 9&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
Pls tell me how I can rectify the error.I am writing the code for finding DFTs without using the matlab command 'fft'</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 21:36:53 -0500</pubDate>
      <title>Re: DFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264879#691851</link>
      <author>TideMan</author>
      <description>On Nov 4, 10:14&#160;am, &quot;Madhumitha Iyer&quot; &amp;lt;pyarsa_ma...@yahoo.co.in&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; x=[zeros(1,10),ones(1,15),zeros(1,10)]; &#160; &#160;%square wave generator&lt;br&gt;
&amp;gt; %The total number of samples are 10+15+10=35&lt;br&gt;
&amp;gt; figure(1)&lt;br&gt;
&amp;gt; subplot(2,1,1)&lt;br&gt;
&amp;gt; plot(x)&lt;br&gt;
&amp;gt; N=35;&lt;br&gt;
&amp;gt; for k=0:N-1&lt;br&gt;
&amp;gt; &#160; &#160; for n=0:N-1&lt;br&gt;
&amp;gt; &#160; &#160; &#160; &#160; x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &#160; &#160; &#160; &#160; subplot(2,1,2)&lt;br&gt;
&amp;gt; plot(x(k))&lt;br&gt;
&amp;gt; &#160; &#160; end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The above code is for finding the DFT coefficients.I am getting the following error while running this program:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Error in ==&amp;gt; DSPnov3 at 9&lt;br&gt;
&amp;gt; &#160; &#160; &#160; &#160; x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; Pls tell me how I can rectify the error.I am writing the code for finding DFTs without using the matlab command 'fft'&lt;br&gt;
&lt;br&gt;
Well, the error message says it all really:&lt;br&gt;
&quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&lt;br&gt;
In other words, you cannot have zero as an index into a vector as you&lt;br&gt;
have done.&lt;br&gt;
You need to start at 1, not zero.&lt;br&gt;
Then, in your summation you must use n-1 and k-1</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 22:08:00 -0500</pubDate>
      <title>Re: DFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264879#691860</link>
      <author>Madhumitha Iyer</author>
      <description>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&lt;br&gt;
Thanx.&lt;br&gt;
&lt;br&gt;
TideMan &amp;lt;mulgor@gmail.com&amp;gt; wrote in message &amp;lt;26b9039c-8b85-4c0b-b0de-f5050f962223@f18g2000prf.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On Nov 4, 10:14?am, &quot;Madhumitha Iyer&quot; &amp;lt;pyarsa_ma...@yahoo.co.in&amp;gt;&lt;br&gt;
&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; x=[zeros(1,10),ones(1,15),zeros(1,10)]; ? ?%square wave generator&lt;br&gt;
&amp;gt; &amp;gt; %The total number of samples are 10+15+10=35&lt;br&gt;
&amp;gt; &amp;gt; figure(1)&lt;br&gt;
&amp;gt; &amp;gt; subplot(2,1,1)&lt;br&gt;
&amp;gt; &amp;gt; plot(x)&lt;br&gt;
&amp;gt; &amp;gt; N=35;&lt;br&gt;
&amp;gt; &amp;gt; for k=0:N-1&lt;br&gt;
&amp;gt; &amp;gt; ? ? for n=0:N-1&lt;br&gt;
&amp;gt; &amp;gt; ? ? ? ? x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &amp;gt; ? ? ? ? subplot(2,1,2)&lt;br&gt;
&amp;gt; &amp;gt; plot(x(k))&lt;br&gt;
&amp;gt; &amp;gt; ? ? end&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; The above code is for finding the DFT coefficients.I am getting the following error while running this program:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Error in ==&amp;gt; DSPnov3 at 9&lt;br&gt;
&amp;gt; &amp;gt; ? ? ? ? x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &amp;gt; Pls tell me how I can rectify the error.I am writing the code for finding DFTs without using the matlab command 'fft'&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Well, the error message says it all really:&lt;br&gt;
&amp;gt; &quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In other words, you cannot have zero as an index into a vector as you&lt;br&gt;
&amp;gt; have done.&lt;br&gt;
&amp;gt; You need to start at 1, not zero.&lt;br&gt;
&amp;gt; Then, in your summation you must use n-1 and k-1</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 22:48:01 -0500</pubDate>
      <title>Re: DFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264879#691870</link>
      <author>Wayne King</author>
      <description>&quot;Madhumitha Iyer&quot; &amp;lt;pyarsa_madhu@yahoo.co.in&amp;gt; wrote in message &amp;lt;hcq6eq$855$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; x=[zeros(1,10),ones(1,15),zeros(1,10)];    %square wave generator&lt;br&gt;
&amp;gt; %The total number of samples are 10+15+10=35&lt;br&gt;
&amp;gt; figure(1)&lt;br&gt;
&amp;gt; subplot(2,1,1)&lt;br&gt;
&amp;gt; plot(x)&lt;br&gt;
&amp;gt; N=35;&lt;br&gt;
&amp;gt; for k=0:N-1&lt;br&gt;
&amp;gt;     for n=0:N-1&lt;br&gt;
&amp;gt;         x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt;         subplot(2,1,2)&lt;br&gt;
&amp;gt; plot(x(k))&lt;br&gt;
&amp;gt;     end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The above code is for finding the DFT coefficients.I am getting the following error while running this program:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Error in ==&amp;gt; DSPnov3 at 9&lt;br&gt;
&amp;gt;         x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; Pls tell me how I can rectify the error.I am writing the code for finding DFTs without using the matlab command 'fft'&lt;br&gt;
&lt;br&gt;
Hi, how about simplifying a bit and removing one of your for loops.&lt;br&gt;
&lt;br&gt;
x=[zeros(1,10),ones(1,15),zeros(1,10)]; %square wave generator&lt;br&gt;
%The total number of samples are 10+15+10=35&lt;br&gt;
subplot(2,1,1)&lt;br&gt;
plot(x)&lt;br&gt;
N=35;&lt;br&gt;
for k=1:N&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;freq = (-1i*2*pi*(k-1))/N;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Wnk=exp(freq.*(0:N-1));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;X(k)=sum(x.*Wnk);&lt;br&gt;
end&lt;br&gt;
subplot(2,1,2);&lt;br&gt;
plot(abs(X))&lt;br&gt;
&lt;br&gt;
% you can compare the result against fft() to see they match&lt;br&gt;
figure;&lt;br&gt;
plot(abs(fft(x)));&lt;br&gt;
&lt;br&gt;
Hope that helps,&lt;br&gt;
Wayne</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 23:50:13 -0500</pubDate>
      <title>Re: DFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264879#691881</link>
      <author>TideMan</author>
      <description>On Nov 4, 11:08&#160;am, &quot;Madhumitha Iyer&quot; &amp;lt;pyarsa_ma...@yahoo.co.in&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; 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&lt;br&gt;
&amp;gt; Thanx.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; TideMan &amp;lt;mul...@gmail.com&amp;gt; wrote in message &amp;lt;26b9039c-8b85-4c0b-b0de-f5050f962...@f18g2000prf.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; On Nov 4, 10:14?am, &quot;Madhumitha Iyer&quot; &amp;lt;pyarsa_ma...@yahoo.co.in&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; x=[zeros(1,10),ones(1,15),zeros(1,10)]; ? ?%square wave generator&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; %The total number of samples are 10+15+10=35&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; figure(1)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; subplot(2,1,1)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; plot(x)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; N=35;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; for k=0:N-1&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ? ? for n=0:N-1&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ? ? ? ? x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ? ? ? ? subplot(2,1,2)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; plot(x(k))&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ? ? end&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; The above code is for finding the DFT coefficients.I am getting the following error while running this program:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Error in ==&amp;gt; DSPnov3 at 9&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ? ? ? ? x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Pls tell me how I can rectify the error.I am writing the code for finding DFTs without using the matlab command 'fft'&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Well, the error message says it all really:&lt;br&gt;
&amp;gt; &amp;gt; &quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; In other words, you cannot have zero as an index into a vector as you&lt;br&gt;
&amp;gt; &amp;gt; have done.&lt;br&gt;
&amp;gt; &amp;gt; You need to start at 1, not zero.&lt;br&gt;
&amp;gt; &amp;gt; Then, in your summation you must use n-1 and k-1&lt;br&gt;
&lt;br&gt;
No, No, No, No!!&lt;br&gt;
I guess you have a problem listening.&lt;br&gt;
Matlab has told you and I have re-iterated that you cannot have zero&lt;br&gt;
as an index.  Yet you persist.&lt;br&gt;
It will only work when you pay attention to what Matlab is telling&lt;br&gt;
you.&lt;br&gt;
Start your bloody loops with 1, not zero!</description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 01:07:02 -0500</pubDate>
      <title>Re: DFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264879#691888</link>
      <author>Madhumitha Iyer</author>
      <description>Thanx the code worked fine with your suggestion.Thank you once again&lt;br&gt;
&lt;br&gt;
&quot;Wayne King&quot; &amp;lt;wmkingty@gmail.com&amp;gt; wrote in message &amp;lt;hcqbv1$kve$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Madhumitha Iyer&quot; &amp;lt;pyarsa_madhu@yahoo.co.in&amp;gt; wrote in message &amp;lt;hcq6eq$855$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; x=[zeros(1,10),ones(1,15),zeros(1,10)];    %square wave generator&lt;br&gt;
&amp;gt; &amp;gt; %The total number of samples are 10+15+10=35&lt;br&gt;
&amp;gt; &amp;gt; figure(1)&lt;br&gt;
&amp;gt; &amp;gt; subplot(2,1,1)&lt;br&gt;
&amp;gt; &amp;gt; plot(x)&lt;br&gt;
&amp;gt; &amp;gt; N=35;&lt;br&gt;
&amp;gt; &amp;gt; for k=0:N-1&lt;br&gt;
&amp;gt; &amp;gt;     for n=0:N-1&lt;br&gt;
&amp;gt; &amp;gt;         x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &amp;gt;         subplot(2,1,2)&lt;br&gt;
&amp;gt; &amp;gt; plot(x(k))&lt;br&gt;
&amp;gt; &amp;gt;     end&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; The above code is for finding the DFT coefficients.I am getting the following error while running this program:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Error in ==&amp;gt; DSPnov3 at 9&lt;br&gt;
&amp;gt; &amp;gt;         x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &amp;gt; Pls tell me how I can rectify the error.I am writing the code for finding DFTs without using the matlab command 'fft'&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi, how about simplifying a bit and removing one of your for loops.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x=[zeros(1,10),ones(1,15),zeros(1,10)]; %square wave generator&lt;br&gt;
&amp;gt; %The total number of samples are 10+15+10=35&lt;br&gt;
&amp;gt; subplot(2,1,1)&lt;br&gt;
&amp;gt; plot(x)&lt;br&gt;
&amp;gt; N=35;&lt;br&gt;
&amp;gt; for k=1:N&lt;br&gt;
&amp;gt;     freq = (-1i*2*pi*(k-1))/N;&lt;br&gt;
&amp;gt;     Wnk=exp(freq.*(0:N-1));&lt;br&gt;
&amp;gt;     X(k)=sum(x.*Wnk);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; subplot(2,1,2);&lt;br&gt;
&amp;gt; plot(abs(X))&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % you can compare the result against fft() to see they match&lt;br&gt;
&amp;gt; figure;&lt;br&gt;
&amp;gt; plot(abs(fft(x)));&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hope that helps,&lt;br&gt;
&amp;gt; Wayne</description>
    </item>
    <item>
      <pubDate>Thu, 05 Nov 2009 03:04:21 -0500</pubDate>
      <title>Re: DFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264879#692267</link>
      <author>Greg Heath</author>
      <description>On Nov 3, 8:07&#160;pm, &quot;Madhumitha Iyer&quot; &amp;lt;pyarsa_ma...@yahoo.co.in&amp;gt; wrote:&lt;br&gt;
&amp;gt; Thanx the code worked fine with your suggestion.Thank you once again&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &quot;Wayne King&quot; &amp;lt;wmkin...@gmail.com&amp;gt; wrote in message &amp;lt;hcqbv1$kv...@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Madhumitha Iyer&quot; &amp;lt;pyarsa_ma...@yahoo.co.in&amp;gt; wrote in message &amp;lt;hcq6eq$85...@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; x=[zeros(1,10),ones(1,15),zeros(1,10)]; &#160; &#160;%square wave generator&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; %The total number of samples are 10+15+10=35&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; figure(1)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; subplot(2,1,1)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; plot(x)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; N=35;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; for k=0:N-1&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &#160; &#160; for n=0:N-1&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &#160; &#160; &#160; &#160; x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &#160; &#160; &#160; &#160; subplot(2,1,2)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; plot(x(k))&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &#160; &#160; end&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; The above code is for finding the DFT coefficients.I am getting the following error while running this program:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &quot;Subscript indices must either be real positive integers or logicals.&quot;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Error in ==&amp;gt; DSPnov3 at 9&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &#160; &#160; &#160; &#160; x(k)=sum(x(n)*(exp(-j*2*pi*n*k/N)));&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Pls tell me how I can rectify the error.I am writing the code for finding DFTs without using the matlab command 'fft'&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Hi, how about simplifying a bit and removing one of your for loops.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; x=[zeros(1,10),ones(1,15),zeros(1,10)]; %square wave generator&lt;br&gt;
&amp;gt; &amp;gt; %The total number of samples are 10+15+10=35&lt;br&gt;
&amp;gt; &amp;gt; subplot(2,1,1)&lt;br&gt;
&amp;gt; &amp;gt; plot(x)&lt;br&gt;
&amp;gt; &amp;gt; N=35;&lt;br&gt;
&amp;gt; &amp;gt; for k=1:N&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160; freq = (-1i*2*pi*(k-1))/N;&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160; Wnk=exp(freq.*(0:N-1));&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160; X(k)=sum(x.*Wnk);&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; subplot(2,1,2);&lt;br&gt;
&amp;gt; &amp;gt; plot(abs(X))&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; % you can compare the result against fft() to see they match&lt;br&gt;
&amp;gt; &amp;gt; figure;&lt;br&gt;
&amp;gt; &amp;gt; plot(abs(fft(x)));&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Hope that helps,&lt;br&gt;
&amp;gt; &amp;gt; Wayne&lt;br&gt;
&lt;br&gt;
The DFT calculation can be simplified further using no loops.&lt;br&gt;
Just matrix multiplication.&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
  </channel>
</rss>

