Finding values of a response within range of a cue

I have a matrix of two columns. The first column is cue times, as in times an animal was cued to do something. The second column is times that the animal responded. If the animal correctly responded then the animal will respond within a range of .15 seconds of cue and less then 5 seconds from cue. If so this is a correct behavior and needs to go into one matrix, if not then this is an error behavior and needs to go in another matrix.
This is the code I have written, but I am not sure why exactly it is not working.
Here is my code:
data=intervals;
cue=data(:,1);
response=data(:,2);
for k=1:length(cue)
for i=1:length(response)
if cue(k)+.15 >= response(i) && cue(k)+5<= response(i)
correct(i)=response(i);
else
error(i)=response(i);
end
end
end
I attached an example matrix of intervals.
Any help would be greatly appreciated.

3 comentarios

per isakson
per isakson el 1 de Dic. de 2016
Editada: per isakson el 1 de Dic. de 2016
  • In what way does the code fail?
  • What is the expected behavior?
  • What is the unit of the data in intervals.mat
James Tursa
James Tursa el 1 de Dic. de 2016
Note: error() is the name of a MATLAB intrinsic function. You should choose another name for your variable.
Sorry about error(), I will change that.
The code fails for my criteria in that points 735.18, 1442.1, 1682.2, 1961.4, 2681.8,2682.1, 3499 should go to correct because they are after .15 seconds after and 5 seconds less then time points in first column.
Does my criteria make sense?
correct = response times greater than .15 second AND less than 5 seconds of any cue time
error = all other response times that are not correct

Iniciar sesión para comentar.

 Respuesta aceptada

bio lim
bio lim el 1 de Dic. de 2016
Editada: bio lim el 1 de Dic. de 2016
Take a look at your data (which is the same as intervals).
data =
81.436 735.18
272.1 1442.1
515.3 1682.2
575.42 1961.6
734.96 2507.1
915.2 2681.8
1319.4 2682.1
1441 2777.7
1526.6 3499
1681.5 0
1961.4 0
2087 0
2372.6 0
2559.9 0
2681.7 0
2838.6 0
3049.3 0
3141 0
3322.4 0
3498.9 0
None of the data satisfies your criteria, i.e.,
if cue(k)+.15 >= response(i) && cue(k)+5<= response(i)
correct(i)=response(i);
Hence all of them would go to error.
Your program is working fine, it's that your data doesn't qualify as the correct behavior.

4 comentarios

The criteria I am intending to find should give me 735.18 for the data point 734.96, 1442.1 for 1441, 1682.2 for 1681.5, 1961.6 for 1961.4 etc. I want data points after .15 seconds of the cue and less than five seconds of the cue.
bio lim
bio lim el 1 de Dic. de 2016
Editada: bio lim el 1 de Dic. de 2016
I don't understand. Your condition is:
If the animal correctly responded then the animal will respond within a range of .15 seconds of cue and less then 5 seconds from cue.
However, your response data suggests that your criteria was not met.
What do you mean by:
give me 735.18 for the data point 734.96, 1442.1 for 1441, 1682.2 for 1681.5, 1961.6 for 1961.4 etc. I want data points after .15 seconds of the cue and less than five seconds of the cue.
Do you just want to add .15 seconds to each cue? Or am I getting it wrong? What are the units for each columns in your data?
per isakson
per isakson el 1 de Dic. de 2016
  • milliseconds ???
My apologies,
It should have been written:
if reward(i)>= (cue(k)+.15) && reward(i)<= (cue(k)+5)

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 1 de Dic. de 2016

Comentada:

el 1 de Dic. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by