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 greater than .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(correcttrials), if not then this is an error behavior and needs to go in a second matrix(errortrials).
The original Matrix (I have also attached it):
intervals = 81.4358 735.1798272.0970 1442.0839515.2985 1682.2252575.41885 1961.58675734.95985 2507.14965915.20085 2681.830551319.4032 2682.07051441.0439 2777.67101526.62435 3498.99471681.4852 01961.38675 02087.0074 02372.6089 02559.9099 02681.73055 02838.63135 03049.3324 03140.97285 03322.3738 03498.87465 0
This is the code I have written, but I am not sure why the correct output has zeros in it and the error output gets all zeros.
Here is my code:
data=intervals;cue=data(:,1);response=data(:,2); for k=1:length(cue) for i=1:length(response) if reward(i)>= (cue(k)+.15) && reward(i)<= (cue(k)+5) correcttrials(i)=response(i); else errortrials(i)=response(i); end endend
Here are the Matrices I am getting out:
Correct Trials:
correcttrials=735.1798 1442.0839 1682.2252 1961.58675 735.1798 0 2682.0705 1442.0839 0 1682.2252 1961.58675 0 0 0 2682.0705
Error Trials:
errortrials = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I am intending to get:
Correct Trials:
correcttrials = 735.1798 1442.0839 1682.2252 1961.58675 2682.0705
Error Trials:
errortrials = 2507.14965 2681.83055 2777.6710 3498.9947
Best Answer