| Author |
Message |
ricky2882
Joined: 01 Dec 2005
Posts: 4
|
Posted:
Thu Dec 01, 2005 10:45 am Post subject:
xcorr in MATLAB |
|
|
Hi,
I have a seemingly simple problem that i can't manage to solve. I need to make a
cross correlogram of two 'spike trains'. I have two files, each of one column giving
the times of a 'spike'. So for example the two files could be:
A:
0.8582
0.8762
0.8932
1.0541
1.0833
1.1006
and B:
0.8582
0.8762
0.8932
1.0541
1.0833
1.1006
1.1180
(They are in increasing order, since these are the times (in sec.) at which a spike
occurred). The two files have different no. of spike times. The heights of the
spikes are not important (0 or 1), with the above times giving the times for 1's to
occur.
I did C = xcorr(A,B), and plotted C. Now I don't know what the horizontal axis is,
and i get a weird triangular peak. I've obviously done something wrong.
My question, then: How do i use xcorr to create a cross correlogram of the two files
A and B? Please help. |
|
| Back to top |
|
 |
ricky2882
Joined: 01 Dec 2005
Posts: 4
|
Posted:
Thu Dec 01, 2005 12:13 pm Post subject:
re:xcorr in MATLAB |
|
|
| Can I use xcorr to create a cross-correlogram of two digital signals? If not how do I do it? |
|
| Back to top |
|
 |
Guest
|
Posted:
Thu Dec 01, 2005 11:23 pm Post subject:
Re: xcorr in MATLAB |
|
|
ricky2882 wrote:
| Quote: | Hi,
I have a seemingly simple problem that i can't manage to solve.
|
Been busy with the same thing for the last three days ... :-(
....
| Quote: | I did C = xcorr(A,B), and plotted C. Now I don't know what the
horizontal axis is,
and i get a weird triangular peak. I've obviously done something
wrong.
|
No, you did everything fine (the triangular peak is the cross
correlation of two more or less rectangular signals). The question you
have to ask yourself: Why do you want the cross correlation between A
and B?
Regards,
Andor |
|
| Back to top |
|
 |
ricky2882
Joined: 01 Dec 2005
Posts: 4
|
Posted:
Fri Dec 02, 2005 5:09 am Post subject:
re:xcorr in MATLAB |
|
|
| Well, one signal is from electrophysiology expts. (i'm doing a neuroscience project), and the other one is obtained from simulations of the same data. I want to show that my model is working fine ie it's giving a pattern similar to that obtained by 'real' expts. I want to know what my x-axis is. I want my correlogram to have a horizontal axis as time. But this does not seem to be the case here. |
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Dec 02, 2005 3:48 pm Post subject:
Re: re:xcorr in MATLAB |
|
|
ricky2882 wrote:
| Quote: | Well, one signal is from electrophysiology expts. (i'm doing a
neuroscience project), and the other one is obtained from simulations
of the same data. I want to show that my model is working fine ie it's
giving a pattern similar to that obtained by 'real' expts.
|
In that case I would analyse the interarrival times of the spikes (ie
your signal differentiated). Perhaps it makes sense to assume that the
interarrival times are exponentially iid distributed (you can test that
on the data from the experts). If you can show that your model produces
similar expentially distributed data (ie. the lambda parameter is
similar to the lambda of the real data), then you have shown that the
statistics of the data generated by your model matches that of the real
data.
| Quote: | I want to
know what my x-axis is. I want my correlogram to have a horizontal
axis as time. But this does not seem to be the case here.
|
I'm not sure the cross correlation is a sensible measure for this case.
That is probably why you can't make sense of the results you are
getting.
Regards,
Andor |
|
| Back to top |
|
 |
ricky2882
Joined: 01 Dec 2005
Posts: 4
|
Posted:
Fri Dec 02, 2005 4:01 pm Post subject:
re:xcorr in MATLAB |
|
|
I got it fixed (for those with a similar problem):
a=load('filename1')
b=load('filename2')
y=zeros(1,30000); % blank canvas
x=y; % and another
x(round(a*1000))=1;% insert impulses
y(round(b*1000))=1;% and again
z=xcorr(x,y); % correlate
plot(z); % plot result
(realise the concept, and the mistake i was making)
the horizontal axis is now in milliseconds (if the original filles had the entries in seconds), because of the multiplying with 1000.
[q,lags]=xcorr(x,y) will give the values of the lags (the x-axis). By default, the file does not plot centred at 0. |
|
| Back to top |
|
 |
|
|
|
|