Hi guys,
So I have this vector with 182 elements that show me timings of a neuron's spiking activity. Each element corresponds to a time point, for e.g. 672 where 672 is in ms.
My timeline is 10s or 10000 ms.
What I need to generate is a vector with 10000 elements, where there are 1s at the times corresponding to the spike-timing matrix and 0s everywhere else.
The code I wrote shows me only one 1, that too at the last time point. Here is what I wrote -
spikes = zeros(1,length(time));
s = SpikeTimes*10;
for j = 1:length(SpikeTimes)
for i = 1:length(spikes)
if s(j) ~= i
spikes(i) = 0;
else
spikes(i) = 1;
end
end
end
Could anyone please help me out? Thanks.
I need to further use the generated spikes vector to calculate firing rate using binning, a rectangular window, a gaussian window and compare and discuss the results.

 채택된 답변

Matt Tearle
Matt Tearle 2011년 5월 3일

0 개 추천

Perhaps I misunderstand, but you should be able to do simply:
spikes(SpikeTimes*10) = 1;
Example:
x = [1 2 7 14 17]
y = zeros(1,20);
y(x) = 1

댓글 수: 6

Abhilash
Abhilash 2011년 5월 3일
Nope, that didn' work. What actually worked was taking away the 'else' clause. Weird.
Abhilash
Abhilash 2011년 5월 3일
Oh not weird. I get why taking away the else clause worked.
Matt Tearle
Matt Tearle 2011년 5월 3일
What does SpikeTimes look like? Is this the 182-element vector of timings (672 etc)?
Abhilash
Abhilash 2011년 5월 3일
Yes. It has timings starting at 672 and ending at 8606
Matt Tearle
Matt Tearle 2011년 5월 3일
OK so:
spikes = zeros(...)
spikes(SpikeTimes) = 1;
Abhilash
Abhilash 2011년 5월 3일
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Dimithra Anton
Dimithra Anton 2020년 9월 13일

0 개 추천

spikes = zeros(1,length(time));
spikes = zeros(1,length(time))

댓글 수: 2

Adam Danz
Adam Danz 2020년 9월 13일
편집: Adam Danz 2020년 9월 13일
spike = zeros(size(time));
to maintain the same shape.
Also avoid using length() since you never know what dimension it will return if your data aren't a vector. Instead, use
spike = zeros(1,numel(time));
Abhilash
Abhilash 2020년 9월 13일
Wow this was 9 years ago!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Electrophysiology에 대해 자세히 알아보기

질문:

2011년 5월 3일

댓글:

2020년 9월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by