22 lines
719 B
Matlab
22 lines
719 B
Matlab
function [isicorr, lags] = isiserialcorr(isivec, maxlag)
|
|
% serial correlation of interspike intervals
|
|
%
|
|
% Arguments:
|
|
% isivec: vector of interspike intervals in seconds
|
|
% maxlag: the maximum lag
|
|
%
|
|
% Returns:
|
|
% isicorr: vector with the serial correlations for lag 0 to maxlag
|
|
% lags: vector with the lags corresponding to isicorr
|
|
lags = 0:maxlag;
|
|
isicorr = zeros(size(lags));
|
|
for k = 1:length(lags)
|
|
lag = lags(k);
|
|
if length(isivec) > lag+10 % ensure "enough" data
|
|
% NOTE: the arguments to corr must be column vectors!
|
|
% We insure this already in the isis() function.
|
|
isicorr(k) = corr(isivec(1:end-lag), isivec(lag+1:end));
|
|
end
|
|
end
|
|
end
|