From: Jesse on
> Well, it isn't _exactly_ what I suggested, that's the result of the two
> lines in the loop, not the two find() operations.
>
> Here's your code snippit again...
>
> % PARSE TE INTO A CORTEX-LIKE DATA STRUCTURE
> BeginTrial = find(TimesEvents(:,2)==STARTCODE);
> EndTrial = find(TimesEvents(:,2)==STOPCODE);
> for t = 1:length(BeginTrial)
> times = TimesEvents(BeginTrial(t):EndTrial(t),1);
> codes = TimesEvents(BeginTrial(t):EndTrial(t),2);
> ...
>
> It's clear the second pass fails since the first time the two arrays are
> not empty.
>
> Again, instead of looking at the times and codes arrays alone, look at
>
> BeginTrial = find(TimesEvents(:,2)==STARTCODE)
> EndTrial = find(TimesEvents(:,2)==STOPCODE)
>
> I'm quite sure you'll find a problem there in the second instance for
> this data set.

You Win!!
When i pasted the two 'start' and 'stop' arrays into Excel and subtracted them, two things jumped out at me:
first, about halfway through the data set the difference became negative.
second, there were 2 more entries in the 'stop' column than the 'start.'

i include a 'catch' trial in the task twice -- once in the exact middle, and once at the end. and it turns out that in the code that controls *this* trial, i had forgotten to put a line for 'startcode' (but 'stopcode' was still there.)

so Matlab was just fine -- it was my mistake. it was properly finding the 2 extra 'stop's and choking when the rest of the data didn't match up.

Problem resolved -- Thank You.
From: dpb on
Jesse wrote:
....

> When i pasted the two 'start' and 'stop' arrays into Excel and
> subtracted them, two things jumped out at me:
> first, about halfway through the data set the difference became negative.
> second, there were 2 more entries in the 'stop' column than the 'start.'

Wouldn't it have been easier to have stayed in Matlab in the debug mode
or even simply print the arrays in question by dropping the ";"'s???

....

> so Matlab was just fine -- it was my mistake. it was properly finding
> the 2 extra 'stop's and choking when the rest of the data didn't match up.
> Problem resolved -- Thank You.

Yes, looking at the code it was clear that the reason for an empty array
was in all likelihood that the first:last selection was returning null
results because either the condition wasn't found or first>last for a case.

Believe the machine to do what you tell it; not what you want... :)

--