From: Pieta Brown on
Hi there,
I have two sets of data, one containing points with time stamps from sets X andY and a corresponding value of 0/1(relating to a particular aspect of animal behaviour)
The second set contains only the points Y.
The points Y determine particular states, ie s1 is given as a function of Y2-Y1
I need to determine the proportion of each state which is spent in '0' or in '1', in other words, the points Y break the X's up into state groups.

I will call the sets 'XandY' and 'justY'

I am not sure why the following won't work?

for i=1:(length(justY)-1)
for j=1:(length(XandY)-1)
c=zeros(1,length(XandY))
if Y(i)<=X(j) & X(j+1)<=Y(i+1)
c(i)=c(i)+(Time(j+1)-Time(j))*Immersion1(j)
else
c(i)=c(i)
end
end
end

Any help would be very much appreciated!
From: dpb on
Pieta Brown wrote:
> Hi there,
> I have two sets of data, one containing points with time stamps from
> sets X andY and a corresponding value of 0/1(relating to a particular
> aspect of animal behaviour)
> The second set contains only the points Y.
> The points Y determine particular states, ie s1 is given as a function
> of Y2-Y1
> I need to determine the proportion of each state which is spent in '0'
> or in '1', in other words, the points Y break the X's up into state groups.
>
> I will call the sets 'XandY' and 'justY'
>
> I am not sure why the following won't work?
>
> for i=1:(length(justY)-1)
> for j=1:(length(XandY)-1)
> c=zeros(1,length(XandY))
> if Y(i)<=X(j) & X(j+1)<=Y(i+1)
> c(i)=c(i)+(Time(j+1)-Time(j))*Immersion1(j)
> else
> c(i)=c(i)
> end
> end
> end
>
> Any help would be very much appreciated!

First for what definition of "won't work"?

Where/what's Immersion1()?

How are the timestamps coded?

--