EEG ~ Compare section of sample data with entire sample

I have having some trouble with my code. I am trying to take a small portion of my code and want to correlate it with the entire data. Trying to sweep the 25 data points I selected with the original 25 data points. I am getting an error message and I don't know how to sweep across all the data.
??? Error using ==> horzcat CAT arguments dimensions are not consistent.
Error in ==> EE127_PostLab4 at 153 R=[b,c];
My code is below.
for i=1:230
b=eeg2c3(i:230);
c=eeg2c3(95:120);
d=b(i:25);
R=xcorr (b,c);
b=b-25;
end
figure ('Name', 'Test', 'NumberTitle', 'off');
plot (R);
This is what it's plotting

Answers (1)

You would get that problem if eeg2c3 is a column vector. If you are expecting column vectors, use [b;c] instead of [b,c]

4 Comments

Oh. I think I gave you my old code. The code I'm using now does not give me an error, but it won't shift and compare with the rest of the data. The code I'm using now is
for i=1:230
b=eeg2c3(i:230);
c=eeg2c3(95:120);
d=b(i:25);
R=xcorr (b,c);
b=b-25;
end
figure ('Name', 'Test', 'NumberTitle', 'off');
plot (R);
That code gives me this image:
http://i41.tinypic.com/e8u25s.jpg
I'm having to make some guesses about what you are doing.
c = eeg2c3(95:120);
for i=1:230-24
b = eeg2c3(i:i+24);
R(i) = xcorr(b,c);
end
plot(R);
That's great. Thanks for your help. I had to make a change since R(i) didn't work for me. I used [C, lags] =...

Sign in to comment.

Categories

Asked:

on 18 Apr 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!