If you type
dbstop if error
in the command window and then run ftest again, it should stop at line 46 of culc_fft with a green arrow. Then you could move the mouse cursor over i and epoch to see their values as Matt said. You could also highlight [just like selecting a part of a text] the expression you like and rightclick and say evaluate to see what it is. The output will be printed in the command window. This way you could examine the value of not only epoch, the whole vector, but also epoch(2) for example, or even epoch(1):epoch(2). It depends on to what extent you will highlight the code.
"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*(j1);
> epoch = [es es+length1];
>
> 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
