Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
A question regarding FFT program

Subject: A question regarding FFT program

From: Masako Tamaki

Date: 7 Jun, 2009 12:58:01

Message: 1 of 3

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

Subject: A question regarding FFT program

From: Matt

Date: 7 Jun, 2009 13:17:02

Message: 2 of 3

"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)

Subject: A question regarding FFT program

From: Sadik

Date: 7 Jun, 2009 13:36:01

Message: 3 of 3

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 right-click 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*(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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us