MATLAB: Find previous time conditions were met, save it as new marix

dataMATLABvectors

I am working with ecology data. Presence/absence data (Y) has been collected for 100 sites (X) over 10 years (Z), on a rotational basis (30 per year). To illusterate: site X(1) could, for example, be surveyed year [1,4,7,10], site X(2) surveyed year [2,3,4,8], site X(3) surveyed [3,5].
To better explain observed presence/absence (Y) in a given year z I would like to use presence/absence data (Y) from the previous time a given site x was surveyed.
I am at a loss where to begin. Any advice/pointers to get me started would be much appreciated.
Many thanks
J

Best Answer

Joel, it's hard to tell, but it seems very likely that you'd benefit from putting your data in a timetable. "30 per year" sounds like you have timestamps to a resolution smaller than whole years. Timetables let you select data by time.
You could also convert your species and sites to categorical. You might find it more palatable to write
mydata(mydata.Species1=='Cryptobranchus alleganiensis' & mydata.Site=='Oneonta',:)
to select data.