Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: A question regarding FFT program
Date: Sun, 7 Jun 2009 13:17:02 +0000 (UTC)
Organization: Xoran Technologies
Lines: 51
Message-ID: <h0geke$nd5$1@fred.mathworks.com>
References: <h0gdgp$9t2$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 1244380622 23973 172.30.248.35 (7 Jun 2009 13:17:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 7 Jun 2009 13:17:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:545325


"Masako Tamaki" <michamel41@yahoo.co.jp> wrote in message <h0gdgp$9t2$1@fred.mathworks.com>...
> Hi,
> I am a beginner user of Matlab. I'd like to FFT EEG data, but I got the following error message:
> 
> >> ftest
> Elapsed time is 3.419000 seconds.
> ??? Index exceeds matrix dimensions.
> 
> Error in ==> culc_fft at 46
>             w = val(i, epoch(1):epoch(2));
> 
> Error in ==> Ftest at 57
>                 pow = culc_fft(bpw, len, frq, No_ave, win, start);
> 
> Here is the culc_fft:
> 
> function [Pyy] = culc_fft(val, length, frq, No_ave, win, start);
> No_ch = size(val, 1);
> period = size(start, 1);      
> Pyy = zeros(No_ch, size(frq, 2), period);              
> rep = length/4;
>     for k = 1:period               
> 
>     for j = 1:No_ave    
>         es = start(k) + length*(j-1);
>         epoch = [es es+length-1];
>     
>         for i = 1:No_ch    
>             w = val(i, epoch(1):epoch(2));
>             w = (w - mean(w)).* win;
>     
>             y = fft(w);
>             y(:, size(frq, 2)+1:end) = [];
>             Pyy(i, :, k) =Pyy(i, :, k) + y.* conj(y);
>         end
>     end
> end
> 
> for k = 1:period
>     for i = 1:size(val, 1)     
>         Pyy(i, :, k) = Pyy(i, :, k)./ (length*rep*No_ave);
>     end
> end
> 
> 
> Could someone give me some suggestions to solve this problem?
> Thank you,
> Masako


I suggest you examine the values of i, epoch(1) and epoch(2) and fgure out why one of them is  greater than size(val)