# Need to loop through 2 vectors of 0's and 1's, if a 1 occurs in vector 1 before vector 2, then i need to use a specific eqn. if vector 2 has a 1 before vector 1, then i need to use a seperate eqn.Each vector is the same size.

4 visualizaciones (últimos 30 días)
Joshua Harrison el 22 de Abr. de 2020
Editada: Andrei Bobrov el 22 de Abr. de 2020
I have two vectors that I am working with. 1) Pre_spiketime 2) post_spiketime. The pre_spiketime is a vector (1, 5000) that is zeros if a neuron does not fire and 1 if the neuron does fire. Each column in this represent a time step. The same for post_spiketime. Basially what I want to do is to write a loop that will say if pre_spiketime is before post_spike time (i.e within 20ms) i will use one equation. If post_spiketime is before pre_spiketime by 20ms, then I use another equation. Can someone explain how I can do this.
I also have made these vectors into time points. so instead of a 1, they represent the time at which they fire as well. I dont know if this would help?
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (2)

David Hill el 22 de Abr. de 2020
I assume every pre-spike has a corresponding post-spike.
a=find(preSpike);
b=find(postSpike);
timeDiff=step*(b-a);
%not sure where you want to go from here
##### 2 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
David Hill el 22 de Abr. de 2020
a=find(preSpike);
b=find(postSpike);
for k=a
if ~isempty(b(b>a&b<a+10))%+10? whatever maximum post-spike will occur
%execute what you want
end
end

Iniciar sesión para comentar.

Andrei Bobrov el 22 de Abr. de 2020
Editada: Andrei Bobrov el 22 de Abr. de 2020
Let a - your Pre_spiketime, b - Post_spiketime.
d = a(:) - b(:);
e = d.*[true;diff(d)~=0];
t = e ~= 0;
l = cumsum(t);
out = l;
out(l>0) = 2 - mod(l(l>0),2);
or
lo = l(1) == 0;
if lo, add = 1; end
if lo, out = out(2:end); end
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!